mirror of
https://github.com/IllusionMan1212/vitasdk-odin.git
synced 2026-10-24 02:12:38 +00:00
initial
This commit is contained in:
@@ -0,0 +1,804 @@
|
||||
package kernel
|
||||
|
||||
import "core:c"
|
||||
import sce "../common"
|
||||
|
||||
foreign import libkernel "system:SceLibKernel_stub"
|
||||
|
||||
/** Message Pipe status info */
|
||||
SceKernelMppInfo :: struct {
|
||||
size: sce.Size,
|
||||
mppId: sce.UID, // Needs confirmation
|
||||
name: [32]c.char,
|
||||
attr: sce.UInt,
|
||||
bufSize: c.int,
|
||||
freeSize: c.int,
|
||||
numSendWaitThreads: c.int,
|
||||
numReceiveWaitThreads: c.int,
|
||||
}
|
||||
#assert(size_of(SceKernelMppInfo) == 0x3C)
|
||||
|
||||
/** Additional options used when creating rwlock. */
|
||||
SceKernelRWLockOptParam :: struct {
|
||||
/** Size of the ::SceKernelRWLockOptParam structure */
|
||||
size: sce.Size,
|
||||
}
|
||||
#assert(size_of(SceKernelRWLockOptParam) == 4)
|
||||
|
||||
/** Current state of a rwlock.
|
||||
* @see sceKernelGetRWLockInfo
|
||||
*/
|
||||
SceKernelRWLockInfo :: struct {
|
||||
/** Size of the ::SceKernelRWLockInfo structure */
|
||||
size: sce.Size,
|
||||
/** The UID of the rwlock */
|
||||
rwLockId: sce.UID,
|
||||
/** NULL-terminated name of the rwlock */
|
||||
name: [32]c.char,
|
||||
/** Attributes */
|
||||
attr: sce.UInt32,
|
||||
/** The current lock count */
|
||||
lockCount: sce.Int32,
|
||||
/** The UID of the current owner of the rwlock with write access, 0 when locked for reads */
|
||||
writeOwnerId: sce.UID,
|
||||
/** The number of threads waiting on the rwlock for read access */
|
||||
numReadWaitThreads: sce.UInt32,
|
||||
/** The number of threads waiting on the rwlock for write access */
|
||||
numWriteWaitThreads: sce.UInt32,
|
||||
}
|
||||
#assert(size_of(SceKernelRWLockInfo) == 0x3C)
|
||||
|
||||
SceKernelSystemInfo :: struct {
|
||||
size: sce.Size,
|
||||
activeCpuMask: sce.UInt32,
|
||||
|
||||
cpuInfo: [4]struct {
|
||||
idleClock: sce.KernelSysClock,
|
||||
comesOutOfIdleCount: sce.UInt32,
|
||||
threadSwitchCount: sce.UInt32,
|
||||
},
|
||||
}
|
||||
#assert(size_of(SceKernelSystemInfo) == 0x48)
|
||||
|
||||
@(link_prefix = "sceKernel")
|
||||
foreign libkernel {
|
||||
/**
|
||||
* Fills the output buffer with random data.
|
||||
*
|
||||
* @param[out] output - Output buffer
|
||||
* @param[in] size - Size of the output buffer, 64 bytes maximum
|
||||
*
|
||||
* @return 0 on success, < 0 on error.
|
||||
*/
|
||||
GetRandomNumber :: proc(output: rawptr, size: sce.Size) -> c.int ---
|
||||
|
||||
/**
|
||||
* Gets the status of a specified callback.
|
||||
*
|
||||
* @param cb - The UID of the callback to retrieve info for.
|
||||
* @param status - Pointer to a status structure. The size parameter should be
|
||||
* initialised before calling.
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
GetCallbackInfo :: proc(cb: sce.UID, infop: ^SceKernelCallbackInfo) -> c.int ---
|
||||
|
||||
/**
|
||||
* Creates a new condition variable
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* SceUID condId
|
||||
* condId = sceKernelCreateCond("MyCond", 0, mutexId, NULL)
|
||||
* @endcode
|
||||
*
|
||||
* @param name - Specifies the name of the condition variable
|
||||
* @param attr - Condition variable attribute flags (normally set to 0)
|
||||
* @param mutexId - Mutex to be related to the condition variable
|
||||
* @param option - Condition variable options (normally set to 0)
|
||||
* @return A condition variable id
|
||||
*/
|
||||
CreateCond :: proc(name: cstring, attr: sce.UInt, mutexId: sce.UID, option: ^SceKernelCondOptParam) -> sce.UID ---
|
||||
|
||||
/**
|
||||
* Waits for a signal of a condition variable
|
||||
*
|
||||
* @param condId - The condition variable id returned from ::sceKernelCreateCond
|
||||
* @param timeout - Timeout in microseconds (assumed)
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
WaitCond :: proc(condId: sce.UID, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Waits for a signal of a condition variable (with callbacks)
|
||||
*
|
||||
* @param condId - The condition variable id returned from ::sceKernelCreateCond
|
||||
* @param timeout - Timeout in microseconds (assumed)
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
WaitCondCB :: proc(condId: sce.UID, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Create an event flag.
|
||||
*
|
||||
* @param name - The name of the event flag.
|
||||
* @param attr - Attributes from ::SceEventFlagAttributes
|
||||
* @param bits - Initial bit pattern.
|
||||
* @param opt - Options, set to NULL
|
||||
* @return < 0 on error. >= 0 event flag id.
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* int evid
|
||||
* evid = sceKernelCreateEventFlag("wait_event", 0, 0, NULL)
|
||||
* @endcode
|
||||
*/
|
||||
CreateEventFlag :: proc(name: cstring, attr: c.int, bits: c.int, opt: ^SceKernelEventFlagOptParam) -> sce.UID ---
|
||||
|
||||
/**
|
||||
* Poll an event flag for a given bit pattern.
|
||||
*
|
||||
* @param evid - The event id returned by ::sceKernelCreateEventFlag.
|
||||
* @param bits - The bit pattern to poll for.
|
||||
* @param wait - Wait type, one or more of ::SceEventFlagWaitTypes or'ed together
|
||||
* @param outBits - The bit pattern that was matched.
|
||||
* @return < 0 On error
|
||||
*/
|
||||
PollEventFlag :: proc(evid: c.int, bits: c.uint, wait: c.uint, outBits: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Wait for an event flag for a given bit pattern.
|
||||
*
|
||||
* @param evid - The event id returned by ::sceKernelCreateEventFlag.
|
||||
* @param bits - The bit pattern to poll for.
|
||||
* @param wait - Wait type, one or more of ::SceEventFlagWaitTypes or'ed together
|
||||
* @param outBits - The bit pattern that was matched.
|
||||
* @param timeout - Timeout in microseconds
|
||||
* @return < 0 On error
|
||||
*/
|
||||
WaitEventFlag :: proc(evid: c.int, bits: c.uint, wait: c.uint, outBits: ^c.uint, timeout: ^sce.UInt) -> c.int ---
|
||||
|
||||
/**
|
||||
* Wait for an event flag for a given bit pattern with callback.
|
||||
*
|
||||
* @param evid - The event id returned by ::sceKernelCreateEventFlag.
|
||||
* @param bits - The bit pattern to poll for.
|
||||
* @param wait - Wait type, one or more of ::SceEventFlagWaitTypes or'ed together
|
||||
* @param outBits - The bit pattern that was matched.
|
||||
* @param timeout - Timeout in microseconds
|
||||
* @return < 0 On error
|
||||
*/
|
||||
WaitEventFlagCB :: proc(evid: c.int, bits: c.uint, wait: c.uint, outBits: ^c.uint, timeout: ^sce.UInt) -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the status of an event flag.
|
||||
*
|
||||
* @param event - The UID of the event.
|
||||
* @param status - A pointer to a ::SceKernelEventFlagInfo structure.
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
GetEventFlagInfo :: proc(event: sce.UID, info: ^SceKernelEventFlagInfo) -> c.int ---
|
||||
|
||||
CreateLwCond :: proc(pWork: ^SceKernelLwCondWork, pName: cstring, attr: c.uint, pLwMutex: ^SceKernelLwMutexWork, pOptParam: ^SceKernelLwCondOptParam) -> c.int ---
|
||||
DeleteLwCond :: proc(pWork: ^SceKernelLwCondWork) -> c.int ---
|
||||
SignalLwCond :: proc(pWork: ^SceKernelLwCondWork) -> c.int ---
|
||||
SignalLwCondAll :: proc(pWork: ^SceKernelLwCondWork) -> c.int ---
|
||||
SignalLwCondTo :: proc(pWork: ^SceKernelLwCondWork, threadId: sce.UID) -> c.int ---
|
||||
WaitLwCond :: proc(pWork: ^SceKernelLwCondWork, pTimeout: ^c.uint) -> c.int ---
|
||||
|
||||
CreateLwMutex :: proc(pWork: ^SceKernelLwMutexWork, pName: cstring, attr: c.uint, initCount: c.int, pOptParam: ^SceKernelLwMutexOptParam) -> c.int ---
|
||||
DeleteLwMutex :: proc(pWork: ^SceKernelLwMutexWork) -> c.int ---
|
||||
LockLwMutex :: proc(pWork: ^SceKernelLwMutexWork, lockCount: c.int, pTimeout: ^c.uint) -> c.int ---
|
||||
TryLockLwMutex :: proc(pWork: ^SceKernelLwMutexWork, lockCount: c.int) -> c.int ---
|
||||
UnlockLwMutex :: proc(pWork: ^SceKernelLwMutexWork, unlockCount: c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Create a message pipe
|
||||
*
|
||||
* @param name - Name of the pipe
|
||||
* @param type - The type of memory attribute to use internally (set to 0x40)
|
||||
* @param attr - Set to 12
|
||||
* @param bufSize - The size of the internal buffer in multiples of 0x1000 (4KB)
|
||||
* @param opt - Message pipe options (set to NULL)
|
||||
*
|
||||
* @return The UID of the created pipe, < 0 on error
|
||||
*/
|
||||
CreateMsgPipe :: proc(name: cstring, type: c.int, attr: c.int, bufSize: c.uint, opt: rawptr) -> sce.UID ---
|
||||
|
||||
/**
|
||||
* Send a message to a pipe
|
||||
*
|
||||
* @param uid - The UID of the pipe
|
||||
* @param message - Pointer to the message
|
||||
* @param size - Size of the message
|
||||
* @param unk1 - Unknown - async vs sync? use 0 for sync
|
||||
* @param unk2 - Unknown - use NULL
|
||||
* @param timeout - Timeout for send in us. use NULL to wait indefinitely
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
SendMsgPipe :: proc(uid: sce.UID , message: rawptr, size: c.uint, unk1: c.int, unk2: rawptr, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Send a message to a pipe (with callback)
|
||||
*
|
||||
* @param uid - The UID of the pipe
|
||||
* @param message - Pointer to the message
|
||||
* @param size - Size of the message
|
||||
* @param unk1 - Unknown - async vs sync? use 0 for sync
|
||||
* @param unk2 - Unknown - use NULL
|
||||
* @param timeout - Timeout for send in us. use NULL to wait indefinitely
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
SendMsgPipeCB :: proc(uid: sce.UID, message: rawptr, size: c.uint, unk1: c.int, unk2: rawptr, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Try to send a message to a pipe
|
||||
*
|
||||
* @param uid - The UID of the pipe
|
||||
* @param message - Pointer to the message
|
||||
* @param size - Size of the message
|
||||
* @param unk1 - Unknown - use 0
|
||||
* @param unk2 - Unknown - use NULL
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
TrySendMsgPipe :: proc(uid: sce.UID, message: rawptr, size: sce.Size, unk1: c.int, unk2: rawptr) -> c.int ---
|
||||
|
||||
/**
|
||||
* Receive a message from a pipe
|
||||
*
|
||||
* @param uid - The UID of the pipe
|
||||
* @param message - Pointer to the message
|
||||
* @param size - Size of the message
|
||||
* @param unk1 - Unknown - async vs sync? use 0 for sync
|
||||
* @param unk2 - Unknown - use NULL
|
||||
* @param timeout - Timeout for receive in us. use NULL to wait indefinitely
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
ReceiveMsgPipe :: proc(uid: sce.UID, message: rawptr, size: sce.Size, unk1: c.int, unk2: rawptr, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Receive a message from a pipe (with callback)
|
||||
*
|
||||
* @param uid - The UID of the pipe
|
||||
* @param message - Pointer to the message
|
||||
* @param size - Size of the message
|
||||
* @param unk1 - Unknown - async vs sync? use 0 for sync
|
||||
* @param unk2 - Unknown - use NULL
|
||||
* @param timeout - Timeout for receive in us. use NULL to wait indefinitely
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
ReceiveMsgPipeCB :: proc(uid: sce.UID, message: rawptr, size: sce.Size, unk1: c.int, unk2: rawptr, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Receive a message from a pipe
|
||||
*
|
||||
* @param uid - The UID of the pipe
|
||||
* @param message - Pointer to the message
|
||||
* @param size - Size of the message
|
||||
* @param unk1 - Unknown - use 0
|
||||
* @param unk2 - Unknown - use NULL
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
TryReceiveMsgPipe :: proc(uid: sce.UID, message: rawptr, size: sce.Size, unk1: c.int, unk2: rawptr) -> c.int ---
|
||||
|
||||
|
||||
/**
|
||||
* Cancel a message pipe
|
||||
*
|
||||
* @param uid - UID of the pipe to cancel
|
||||
* @param psend - Receive number of sending threads, NULL is valid
|
||||
* @param precv - Receive number of receiving threads, NULL is valid
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
CancelMsgPipe :: proc(uid: sce.UID, psend: ^c.int, precv: ^c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the status of a Message Pipe
|
||||
*
|
||||
* @param uid - The uid of the Message Pipe
|
||||
* @param info - Pointer to a ::SceKernelMppInfo structure
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
GetMsgPipeInfo :: proc(uid: sce.UID, info: ^SceKernelMppInfo) -> c.int ---
|
||||
|
||||
/**
|
||||
* Creates a new mutex
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* int mutexid
|
||||
* mutexid = sceKernelCreateMutex("MyMutex", 0, 1, NULL)
|
||||
* @endcode
|
||||
*
|
||||
* @param name - Specifies the name of the mutex
|
||||
* @param attr - Mutex attribute flags (normally set to 0)
|
||||
* @param initCount - Mutex initial value
|
||||
* @param option - Mutex options (normally set to 0)
|
||||
* @return A mutex id
|
||||
*/
|
||||
CreateMutex :: proc(name: cstring, attr: sce.UInt, initCount: c.int, option: ^SceKernelMutexOptParam) -> sce.UID ---
|
||||
|
||||
/**
|
||||
* Lock a mutex
|
||||
*
|
||||
* @param mutexid - The mutex id returned from ::sceKernelCreateMutex
|
||||
* @param lockCount - The value to increment to the lock count of the mutex
|
||||
* @param timeout - Timeout in microseconds (assumed)
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
LockMutex :: proc(mutexid: sce.UID, lockCount: c.int, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Lock a mutex and handle callbacks if necessary.
|
||||
*
|
||||
* @param mutexid - The mutex id returned from ::sceKernelCreateMutex
|
||||
* @param lockCount - The value to increment to the lock count of the mutex
|
||||
* @param timeout - Timeout in microseconds (assumed)
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
LockMutexCB :: proc(mutexid: sce.UID, lockCount: c.int, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Cancels a mutex
|
||||
*
|
||||
* @param mutexid - The mutex id returned from ::sceKernelCreateMutex
|
||||
* @param newCount - The new lock count of the mutex
|
||||
* @param numWaitThreads - Number of threads waiting for the mutex
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
CancelMutex :: proc(mutexid: sce.UID, newCount: c.int, numWaitThreads: ^c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Retrieve information about a mutex.
|
||||
*
|
||||
* @param mutexid - UID of the mutex to retrieve info for.
|
||||
* @param info - Pointer to a ::SceKernelMutexInfo struct to receive the info.
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
GetMutexInfo :: proc(mutexid: sce.UID, info: ^SceKernelMutexInfo) -> c.int ---
|
||||
|
||||
/**
|
||||
* Creates a new rwlock
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* int rwlock_id
|
||||
* rwlock_id = sceKernelCreateRWLock("MyRWLock", 0, NULL)
|
||||
* @endcode
|
||||
*
|
||||
* @param name - Specifies the name of the rwlock
|
||||
* @param attr - RWLock attribute flags (normally set to 0)
|
||||
* @param option - RWLock options (normally set to NULL)
|
||||
* @return RWLock id on success, < 0 on error
|
||||
*/
|
||||
CreateRWLock :: proc(name: cstring, attr: sce.UInt32, opt_param: ^SceKernelRWLockOptParam) -> sce.UID ---
|
||||
|
||||
/**
|
||||
* Lock a rwlock with read access
|
||||
*
|
||||
* @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock
|
||||
* @param timeout - Timeout in microseconds, use NULL to disable it
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
LockReadRWLock :: proc(rwlock_id: sce.UID, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Lock a rwlock with write access
|
||||
*
|
||||
* @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock
|
||||
* @param timeout - Timeout in microseconds, use NULL to disable it
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
LockWriteRWLock :: proc(rwlock_id: sce.UID, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Lock a rwlock with read access and handle callbacks
|
||||
*
|
||||
* @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock
|
||||
* @param timeout - Timeout in microseconds, use NULL to disable it
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
LockReadRWLockCB :: proc(rwlock_id: sce.UID, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Lock a rwlock with write access and handle callbacks
|
||||
*
|
||||
* @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock
|
||||
* @param timeout - Timeout in microseconds, use NULL to disable it
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
LockWriteRWLockCB :: proc(rwlock_id: sce.UID, timeout: ^c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Retrieve information about a rwlock.
|
||||
*
|
||||
* @param rwlock_id - UID of the rwlock to retrieve info for.
|
||||
* @param info - Pointer to a ::SceKernelRWLockInfo struct to receive the info.
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
GetRWLockInfo :: proc(rwlock_id: sce.UID, info: ^SceKernelRWLockInfo) -> c.int ---
|
||||
|
||||
/**
|
||||
* Creates a new semaphore
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* int semaid
|
||||
* semaid = sceKernelCreateSema("MySema", 0, 1, 1, NULL)
|
||||
* @endcode
|
||||
*
|
||||
* @param name - Specifies the name of the sema
|
||||
* @param attr - Sema attribute flags (normally set to 0)
|
||||
* @param initVal - Sema initial value
|
||||
* @param maxVal - Sema maximum value
|
||||
* @param option - Sema options (normally set to 0)
|
||||
* @return A semaphore id
|
||||
*/
|
||||
CreateSema :: proc(name: cstring, attr: sce.UInt, initVal: c.int, maxVal: c.int, option: ^SceKernelSemaOptParam) -> sce.UID ---
|
||||
|
||||
|
||||
/**
|
||||
* Lock a semaphore
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* sceKernelWaitSema(semaid, 1, 0)
|
||||
* @endcode
|
||||
*
|
||||
* @param semaid - The sema id returned from ::sceKernelCreateSema
|
||||
* @param signal - The value to wait for (i.e. if 1 then wait till reaches a signal state of 1)
|
||||
* @param timeout - Timeout in microseconds (assumed).
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
WaitSema :: proc(semaid: sce.UID, signal: c.int, timeout: ^sce.UInt) -> c.int ---
|
||||
|
||||
/**
|
||||
* Lock a semaphore and handle callbacks if necessary.
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* sceKernelWaitSemaCB(semaid, 1, 0)
|
||||
* @endcode
|
||||
*
|
||||
* @param semaid - The sema id returned from ::sceKernelCreateSema
|
||||
* @param signal - The value to wait for (i.e. if 1 then wait till reaches a signal state of 1)
|
||||
* @param timeout - Timeout in microseconds (assumed).
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
WaitSemaCB :: proc(semaid: sce.UID, signal: c.int, timeout: ^sce.UInt) -> c.int ---
|
||||
|
||||
/**
|
||||
* Cancels a semaphore
|
||||
*
|
||||
* @param semaid - The sema id returned from ::sceKernelCreateSema
|
||||
* @param setCount - The new lock count of the semaphore
|
||||
* @param numWaitThreads - Number of threads waiting for the semaphore
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
CancelSema :: proc(semaid: sce.UID, setCount: c.int, numWaitThreads: ^c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Retrieve information about a semaphore.
|
||||
*
|
||||
* @param semaid - UID of the semaphore to retrieve info for.
|
||||
* @param info - Pointer to a ::SceKernelSemaInfo struct to receive the info.
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
GetSemaInfo :: proc(semaid: sce.UID, info: ^SceKernelSemaInfo) -> c.int ---
|
||||
|
||||
/**
|
||||
* @brief Sleep current thread and wait for a signal. After it receives a signal, the thread wakes up.
|
||||
*
|
||||
* This is like a semphore with limit 1.
|
||||
* If signal was sent before and not consumed before, the function will immediately return.
|
||||
* @param unk0 unknown parameter. 0 can be used.
|
||||
* @param delay the delay before wating for a signal
|
||||
* @param timeout the timeout if it's null, it waits indefinitely.
|
||||
* @return 0 on success
|
||||
*/
|
||||
WaitSignal :: proc(unk0: sce.UInt32, delay: sce.UInt32, timeout: ^sce.UInt32) -> c.int ---
|
||||
|
||||
/**
|
||||
* Create a thread
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* SceUID thid
|
||||
* thid = sceKernelCreateThread("my_thread", threadFunc, 0x10000100, 0x10000, 0, 0, NULL)
|
||||
* @endcode
|
||||
*
|
||||
* @param name - An arbitrary thread name.
|
||||
* @param entry - The thread function to run when started.
|
||||
* @param initPriority - The initial priority of the thread. Less if higher priority.
|
||||
* @param stackSize - The size of the initial stack.
|
||||
* @param attr - The thread attributes, zero or more of ::SceThreadAttributes.
|
||||
* @param cpuAffinityMask - The CPU affinity mask
|
||||
* A thread can run only on the cores specified in the CPU affinity mask.
|
||||
* The CPU affinity mask can be specified by the logical sum of the following macros:
|
||||
* - SCE_KERNEL_CPU_MASK_USER_0
|
||||
* - SCE_KERNEL_CPU_MASK_USER_1
|
||||
* - SCE_KERNEL_CPU_MASK_USER_2
|
||||
* - SCE_KERNEL_CPU_MASK_SYSTEM (system-reserved core)
|
||||
* The following macro are also available to represent all available in userland CPU cores:
|
||||
* - SCE_KERNEL_CPU_MASK_USER_ALL
|
||||
* The following macro are also available to inherit affinity mask of the calling process:
|
||||
* - SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT
|
||||
* @param option - Additional options specified by ::SceKernelThreadOptParam.
|
||||
|
||||
* @return UID of the created thread, or an error code.
|
||||
*/
|
||||
CreateThread :: proc(name: cstring, entry: SceKernelThreadEntry, initPriority: c.int, stackSize: sce.Size, attr: sce.UInt, cpuAffinityMask: c.int, option: ^SceKernelThreadOptParam) -> sce.UID ---
|
||||
|
||||
|
||||
/**
|
||||
* Start a created thread
|
||||
*
|
||||
* @param thid - Thread id from ::sceKernelCreateThread
|
||||
* @param arglen - Length of the data pointed to by argp, in bytes
|
||||
* @param argp - Pointer to the arguments.
|
||||
*/
|
||||
StartThread :: proc(thid: sce.UID, arglen: sce.Size, argp: rawptr) -> c.int ---
|
||||
|
||||
|
||||
/**
|
||||
* Wait until a thread has ended.
|
||||
*
|
||||
* @param thid - Id of the thread to wait for.
|
||||
* @param stat - Exit status.
|
||||
* @param timeout - Timeout in microseconds (assumed).
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
WaitThreadEnd :: proc(thid: sce.UID, stat: ^c.int, timeout: ^sce.UInt) -> c.int ---
|
||||
|
||||
/**
|
||||
* Wait until a thread has ended and handle callbacks if necessary.
|
||||
*
|
||||
* @param thid - Id of the thread to wait for.
|
||||
* @param stat - Exit status.
|
||||
* @param timeout - Timeout in microseconds (assumed).
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
WaitThreadEndCB :: proc(thid: sce.UID, stat: ^c.int, timeout: ^sce.UInt) -> c.int ---
|
||||
|
||||
/**
|
||||
* Modify the attributes of the current thread.
|
||||
*
|
||||
* @param clearAttr - The thread attributes to clear. One of ::SceThreadAttributes.
|
||||
* @param setAttr - The thread attributes to set. One of ::SceThreadAttributes.
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
ChangeCurrentThreadAttr :: proc(clearAttr: sce.UInt, setAttr: sce.UInt) -> c.int ---
|
||||
|
||||
|
||||
/**
|
||||
* Get the current priority of the thread you are in.
|
||||
*
|
||||
* @return The current thread priority
|
||||
*/
|
||||
GetThreadCurrentPriority :: proc() -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the exit status of a thread.
|
||||
*
|
||||
* @param[in] thid - The UID of the thread to check.
|
||||
* @param[out] status - Status out pointer
|
||||
* @return The exit status
|
||||
*/
|
||||
GetThreadExitStatus :: proc(thid: sce.UID, status: ^c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Check the thread stack?
|
||||
*
|
||||
* @return Unknown.
|
||||
*/
|
||||
CheckThreadStack :: proc() -> c.int ---
|
||||
|
||||
|
||||
/**
|
||||
* Get the status information for the specified thread.
|
||||
*
|
||||
* @param thid - Id of the thread to get status
|
||||
* @param info - Pointer to the info structure to receive the data.
|
||||
* Note: The structures size field should be set to
|
||||
* sizeof(SceKernelThreadInfo) before calling this function.
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* SceKernelThreadInfo status
|
||||
* status.size = sizeof(SceKernelThreadInfo)
|
||||
* if(sceKernelGetThreadInfo(thid, &status) == 0)
|
||||
* { Do something... }
|
||||
* @endcode
|
||||
* @return 0 if successful, otherwise the error code.
|
||||
*/
|
||||
GetThreadInfo :: proc(thid: sce.UID, info: ^SceKernelThreadInfo) -> c.int ---
|
||||
|
||||
/**
|
||||
* Retrive the runtime status of a thread.
|
||||
*
|
||||
* @param thid - UID of the thread to retrieve status.
|
||||
* @param status - Pointer to a ::SceKernelThreadRunStatus struct to receive the runtime status.
|
||||
*
|
||||
* @return 0 if successful, otherwise the error code.
|
||||
*/
|
||||
GetThreadRunStatus :: proc(thid: sce.UID, status: ^SceKernelThreadRunStatus) -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the current thread Id
|
||||
*
|
||||
* @return The thread id of the calling thread.
|
||||
*/
|
||||
GetThreadId :: proc() -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the system information
|
||||
*
|
||||
* @param info - Pointer to a ::SceKernelSystemInfo structure
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
GetSystemInfo :: proc(info: ^SceKernelSystemInfo) -> c.int ---
|
||||
|
||||
/**
|
||||
* @brief sceKernelGetTLSAddr get pointer to TLS key area for current thread
|
||||
* @param key - the TLS keyslot index
|
||||
* @return pointer to TLS key value
|
||||
*/
|
||||
GetTLSAddr :: proc(key: c.int) -> rawptr ---
|
||||
|
||||
AtomicSet8 :: proc(store: ^sce.Int8, value: sce.Int8) ---
|
||||
AtomicSet16 :: proc(store: sce.Int16, value: sce.Int16) ---
|
||||
AtomicSet32 :: proc(store: sce.Int32, value: sce.Int32) ---
|
||||
AtomicSet64 :: proc(store: sce.Int64, value: sce.Int64) ---
|
||||
|
||||
AtomicCompareAndSet8 :: proc(store: sce.Int8, value, SceInt8, new_value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicCompareAndSet16 :: proc(store: sce.Int16, value, SceInt16, new_value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicCompareAndSet32 :: proc(store: sce.Int32, value, SceInt32, new_value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicCompareAndSet64 :: proc(store: sce.Int64, value, SceInt64, new_value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
|
||||
AtomicAddAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicAddAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicAddAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicAddAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicAddUnless8 :: proc(store: sce.Int8, value: sce.Int8, cmpv: sce.Int8) -> sce.Bool ---
|
||||
AtomicAddUnless16 :: proc(store: sce.Int16, value: sce.Int16, cmpv: sce.Int16) -> sce.Bool ---
|
||||
AtomicAddUnless32 :: proc(store: sce.Int32, value: sce.Int32, cmpv: sce.Int32) -> sce.Bool ---
|
||||
AtomicAddUnless64 :: proc(store: sce.Int64, value: sce.Int64, cmpv: sce.Int64) -> sce.Bool ---
|
||||
|
||||
AtomicSubAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicSubAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicSubAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicSubAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicAndAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicAndAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicAndAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicAndAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicOrAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicOrAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicOrAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicOrAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicXorAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicXorAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicXorAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicXorAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicClearAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicClearAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicClearAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicClearAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
|
||||
AtomicGetAndSet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicGetAndSet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicGetAndSet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicGetAndSet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicGetAndAdd8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicGetAndAdd16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicGetAndAdd32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicGetAndAdd64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicGetAndSub8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicGetAndSub16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicGetAndSub32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicGetAndSub64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicGetAndAnd8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicGetAndAnd16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicGetAndAnd32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicGetAndAnd64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicGetAndOr8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicGetAndOr16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicGetAndOr32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicGetAndOr64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicGetAndXor8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicGetAndXor16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicGetAndXor32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicGetAndXor64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
AtomicGetAndClear8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 ---
|
||||
AtomicGetAndClear16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 ---
|
||||
AtomicGetAndClear32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 ---
|
||||
AtomicGetAndClear64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 ---
|
||||
|
||||
|
||||
AtomicClearMask8 :: proc(store: sce.Int8, value: sce.Int8) ---
|
||||
AtomicClearMask16 :: proc(store: sce.Int16, value: sce.Int16) ---
|
||||
AtomicClearMask32 :: proc(store: sce.Int32, value: sce.Int32) ---
|
||||
AtomicClearMask64 :: proc(store: sce.Int64, value: sce.Int64) ---
|
||||
|
||||
AtomicDecIfPositive8 :: proc(store: ^sce.Int8) -> sce.Int8 ---
|
||||
AtomicDecIfPositive16 :: proc(store: ^sce.Int16) -> sce.Int16 ---
|
||||
AtomicDecIfPositive32 :: proc(store: ^sce.Int32) -> sce.Int32 ---
|
||||
AtomicDecIfPositive64 :: proc(store: ^sce.Int64) -> sce.Int64 ---
|
||||
|
||||
|
||||
LoadModule :: proc(path: cstring, flags: c.int, option: ^SceKernelLMOption) -> sce.UID ---
|
||||
UnloadModule :: proc(modid: sce.UID, flags: c.int, option: ^SceKernelULMOption) -> c.int ---
|
||||
|
||||
StartModule :: proc(modid: sce.UID, args: sce.Size, argp: rawptr, flags: c.int, option: rawptr, status: ^c.int) -> c.int ---
|
||||
StopModule :: proc(modid: sce.UID, args: sce.Size, argp: rawptr, flags: c.int, option: rawptr, status: ^c.int) -> c.int ---
|
||||
|
||||
LoadStartModule :: proc(path: cstring, args: sce.Size, argp: rawptr, flags: c.int, option: ^SceKernelLMOption, status: ^c.int) -> sce.UID ---
|
||||
StopUnloadModule :: proc(modid: sce.UID, args: sce.Size, argp: rawptr, flags: c.int, option: ^SceKernelULMOption, status: ^c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Exit current Process with specified return code
|
||||
*
|
||||
* @param[in] res - Exit code to return
|
||||
*
|
||||
* @return 0 on success, < 0 on error.
|
||||
*/
|
||||
ExitProcess :: proc(res: c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the process time of the current process.
|
||||
*
|
||||
* @param[out] type - Pointer to a ::SceKernelSysClock structure which will receive the process time.
|
||||
*
|
||||
* @return 0 on success, < 0 on error.
|
||||
*/
|
||||
GetProcessTime :: proc(pSysClock: ^sce.KernelSysClock) -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the lower 32 bits part of process time of the current process.
|
||||
*
|
||||
* @return process time of the current process
|
||||
*/
|
||||
GetProcessTimeLow :: proc() -> sce.UInt32 ---
|
||||
|
||||
/**
|
||||
* Get the process time of the current process.
|
||||
*
|
||||
* @return process time of the current process
|
||||
*/
|
||||
GetProcessTimeWide :: proc() -> sce.UInt64 ---
|
||||
|
||||
|
||||
|
||||
GetOpenPsId :: proc(id: ^SceKernelOpenPsId) -> c.int ---
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package kernel
|
||||
|
||||
import "core:c"
|
||||
import sce "../common"
|
||||
|
||||
foreign import modulemgr "system:SceKernelModulemgr_stub"
|
||||
|
||||
// missing structs
|
||||
SceKernelLoadModuleOption :: struct {}
|
||||
SceKernelUnloadModuleOption :: struct {}
|
||||
SceKernelLibraryInfo :: struct {}
|
||||
|
||||
@(link_prefix = "sceKernel")
|
||||
foreign modulemgr {
|
||||
GetModuleInfo :: proc(uid: sce.UID, info: ^SceKernelModuleInfo) -> c.int ---
|
||||
GetModuleList :: proc(type: sce.UInt8, uids: [^]sce.UID, num: ^sce.Size) -> c.int ---
|
||||
|
||||
/**
|
||||
* Gets system firmware information.
|
||||
*
|
||||
* @param[out] version - System sw version.
|
||||
*
|
||||
* @note - If you spoofed the firmware version it will return the spoofed firmware.
|
||||
*/
|
||||
GetSystemSwVersion :: proc(version: ^SceKernelSystemSwVersion) -> c.int ---
|
||||
|
||||
@(link_name = "_sceKernelLoadModule")
|
||||
_LoadModule :: proc(module_filename: cstring, flags: sce.UInt32, option: ^SceKernelLoadModuleOption) -> sce.UID ---
|
||||
@(link_name = "_sceKernelLoadStartModule")
|
||||
_LoadStartModule :: proc(module_filename: cstring, args: sce.Size, argp: rawptr, flags: sce.UInt32) -> sce.UID ---
|
||||
@(link_name = "_sceKernelUnloadModule")
|
||||
_UnloadModule :: proc(uid: sce.UID, flags: sce.UInt32, option: ^SceKernelUnloadModuleOption) -> c.int ---
|
||||
@(link_name = "_sceKernelStopModule")
|
||||
_StopModule :: proc(uid: sce.UID, args: sce.Size, argp: rawptr, flags: sce.UInt32) -> c.int ---
|
||||
@(link_name = "_sceKernelStopUnloadModule")
|
||||
_StopUnloadModule :: proc(uid: sce.UID, args: sce.Size, argp: rawptr, flags: sce.UInt32) -> c.int ---
|
||||
|
||||
@(link_name = "_sceKernelOpenModule")
|
||||
_OpenModule :: proc(module_filename: cstring, args: sce.Size, argp: rawptr, flags: sce.UInt32) -> sce.UID ---
|
||||
@(link_name = "_sceKernelCloseModule")
|
||||
_CloseModule :: proc(modid: sce.UID, args: sce.Size, argp: rawptr, flags: sce.UInt32) -> sce.UID ---
|
||||
|
||||
GetLibraryInfoByNID :: proc(modid: sce.UID, libnid: sce.NID, info: ^SceKernelLibraryInfo) -> c.int ---
|
||||
|
||||
IsCalledFromSysModule :: proc(lr: rawptr) -> c.int ---
|
||||
GetModuleIdByAddr :: proc(addr: rawptr) -> sce.UID ---
|
||||
GetAllowedSdkVersionOnSystem :: proc() -> sce.UInt32 ---
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package kernel
|
||||
|
||||
import "core:c"
|
||||
import sce "../common"
|
||||
|
||||
foreign import processmgr "system:SceProcessmgr_stub"
|
||||
|
||||
@(link_prefix = "sceKernel")
|
||||
foreign processmgr {
|
||||
/**
|
||||
* Cancel specified idle timers to prevent entering in power save processing.
|
||||
*
|
||||
* @param[in] type - One of ::SceKernelPowerTickType
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
PowerTick :: proc(type: SceKernelPowerTickType) -> c.int ---
|
||||
|
||||
/**
|
||||
* Locks certain timers from triggering.
|
||||
*
|
||||
* @param[in] type - One of ::SceKernelPowerTickType
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
PowerLock :: proc(type: SceKernelPowerTickType) -> c.int ---
|
||||
|
||||
/**
|
||||
* Unlocks certain timers.
|
||||
*
|
||||
* @param[in] type - One of ::SceKernelPowerTickType
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
PowerUnlock :: proc(type: SceKernelPowerTickType) -> c.int ---
|
||||
|
||||
GetCurrentProcess :: proc() -> sce.UID ---
|
||||
GetRemoteProcessTime :: proc(processId: sce.UID, pClock: ^sce.KernelSysClock) -> sce.Int32 ---
|
||||
|
||||
GetStderr :: proc() -> sce.UID ---
|
||||
GetStdin :: proc() -> sce.UID ---
|
||||
GetStdout :: proc() -> sce.UID ---
|
||||
|
||||
GetProcessParam :: proc() -> rawptr ---
|
||||
|
||||
LibcClock :: proc() -> SceKernelClock ---
|
||||
LibcTime :: proc(tloc: ^SceKernelTime) -> SceKernelTime ---
|
||||
|
||||
LibcGettimeofday :: proc(tv: ^SceKernelTimeval, tz: ^SceKernelTimezone) -> c.int ---
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package kernel
|
||||
|
||||
import "core:c"
|
||||
import sce "../common"
|
||||
|
||||
foreign import sysmem "system:SceSysmem_stub"
|
||||
|
||||
@(link_prefix = "sceKernel")
|
||||
foreign sysmem {
|
||||
GetCpuId :: proc() -> c.int ---
|
||||
|
||||
/**
|
||||
* Allocates a new memory block
|
||||
*
|
||||
* @param[in] name - Name for the memory block
|
||||
* @param[in] type - Type of the memory to allocate. Use `SCE_KERNEL_MEMBLOCK_TYPE_USER_*`.
|
||||
* @param[in] size - Size of the memory to allocate
|
||||
* @param[in] opt - Memory block options?
|
||||
*
|
||||
* @return SceUID of the memory block on success, < 0 on error.
|
||||
*/
|
||||
AllocMemBlock :: proc(name: cstring, type: SceKernelMemBlockType, size: sce.Size, opt: ^SceKernelAllocMemBlockOpt) -> sce.UID ---
|
||||
|
||||
/**
|
||||
* Frees new memory block
|
||||
*
|
||||
* @param[in] uid - SceUID of the memory block to free
|
||||
*
|
||||
* @return 0 on success, < 0 on error.
|
||||
*/
|
||||
FreeMemBlock :: proc(uid: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Gets the base address of a memory block
|
||||
*
|
||||
* @param[in] uid - SceUID of the memory block to free
|
||||
* @param[out] base - Base address of the memory block identified by SceUID
|
||||
*
|
||||
* @return 0 on success, < 0 on error.
|
||||
*/
|
||||
GetMemBlockBase :: proc(uid: sce.UID, base: ^rawptr) -> c.int ---
|
||||
|
||||
FindMemBlockByAddr :: proc(addr: rawptr, size: sce.Size) -> sce.UID ---
|
||||
|
||||
GetMemBlockInfoByAddr :: proc(base: rawptr, info: ^SceKernelMemBlockInfo) -> c.int ---
|
||||
GetMemBlockInfoByRange :: proc(base: rawptr, size: sce.Size, info: ^SceKernelMemBlockInfo) -> c.int ---
|
||||
|
||||
AllocMemBlockForVM :: proc(name: cstring, size: sce.Size) -> sce.UID ---
|
||||
SyncVMDomain :: proc(uid: sce.UID, data: rawptr, size: sce.Size) -> c.int ---
|
||||
OpenVMDomain :: proc() -> c.int ---
|
||||
CloseVMDomain :: proc() -> c.int ---
|
||||
|
||||
OpenMemBlock :: proc(name: cstring, flags: c.int) -> c.int ---
|
||||
CloseMemBlock :: proc(uid: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the model number of the device
|
||||
*
|
||||
* @return A value from SCE_KERNEL_MODEL
|
||||
*/
|
||||
GetModelForCDialog :: proc() -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the model number of the device
|
||||
*
|
||||
* @return A value from SCE_KERNEL_MODEL
|
||||
*/
|
||||
GetModel :: proc() -> c.int ---
|
||||
|
||||
/**
|
||||
* Get free memory size in bytes
|
||||
*
|
||||
* @param[out] info - Returned free memory size for different kind of memory block types
|
||||
* @return 0 on success, < 0 on error.
|
||||
*/
|
||||
GetFreeMemorySize :: proc(info: ^SceKernelFreeMemorySizeInfo) -> c.int ---
|
||||
|
||||
IsPSVitaTV :: proc() -> c.int ---
|
||||
}
|
||||
@@ -0,0 +1,433 @@
|
||||
package kernel
|
||||
|
||||
import "core:c"
|
||||
import sce "../common"
|
||||
|
||||
foreign import threadmgr "system:SceKernelThreadMgr_stub"
|
||||
|
||||
@(link_prefix = "sceKernel")
|
||||
foreign threadmgr {
|
||||
/**
|
||||
* Create callback
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* int cbid
|
||||
* cbid = sceKernelCreateCallback("Exit Callback", 0, exit_cb, NULL)
|
||||
* @endcode
|
||||
*
|
||||
* @param name - A textual name for the callback
|
||||
* @param attr - ?
|
||||
* @param func - A pointer to a function that will be called as the callback
|
||||
* @param userData - User defined data to be passed to the callback.
|
||||
*
|
||||
* @return >= 0 A callback id which can be used in subsequent functions, < 0 an error.
|
||||
*/
|
||||
CreateCallback :: proc(name: cstring, attr: c.uint, func: SceKernelCallbackFunction, userData: rawptr) -> c.int ---
|
||||
|
||||
/**
|
||||
* Delete a callback
|
||||
*
|
||||
* @param cb - The UID of the specified callback
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
DeleteCallback :: proc(cb: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Notify a callback
|
||||
*
|
||||
* @param cb - The UID of the specified callback
|
||||
* @param arg2 - Passed as arg2 into the callback function
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
NotifyCallback :: proc(cb: sce.UID, arg2: c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Cancel a callback ?
|
||||
*
|
||||
* @param cb - The UID of the specified callback
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
CancelCallback :: proc(cb: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the callback count
|
||||
*
|
||||
* @param cb - The UID of the specified callback
|
||||
*
|
||||
* @return The callback count, < 0 on error
|
||||
*/
|
||||
GetCallbackCount :: proc(cb: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Check callback ?
|
||||
*
|
||||
* @return Something or another
|
||||
*/
|
||||
CheckCallback :: proc() -> c.int ---
|
||||
|
||||
/**
|
||||
* Destroy a condition variable
|
||||
*
|
||||
* @param condition variableid - The condition variable id returned from ::sceKernelCreateCond
|
||||
* @return Returns the value 0 if it's successful, otherwise -1
|
||||
*/
|
||||
DeleteCond :: proc(condId: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Open a condition variable
|
||||
*
|
||||
* @param name - The name of the condition variable to open
|
||||
* @return Returns the value 0 if it's successful, otherwise -1
|
||||
*/
|
||||
OpenCond :: proc(name: cstring) -> c.int ---
|
||||
|
||||
/**
|
||||
* Close a condition variable
|
||||
*
|
||||
* @param condition variableid - The condition variable id returned from ::sceKernelCreateCond
|
||||
* @return Returns the value 0 if it's successful, otherwise -1
|
||||
*/
|
||||
CloseCond :: proc(condId: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Signals a condition variable
|
||||
*
|
||||
* @param condId - The condition variable id returned from ::sceKernelCreateCond
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
SignalCond :: proc(condId: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Signals a condition variable to all threads waiting for it
|
||||
*
|
||||
* @param condId - The condition variable id returned from ::sceKernelCreateCond
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
SignalCondAll :: proc(condId: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Signals a condition variable to a specific thread waiting for it
|
||||
*
|
||||
* @param condId - The condition variable id returned from ::sceKernelCreateCond
|
||||
* @param threadId - The thread id returned from ::sceKernelCreateThread
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
SignalCondTo :: proc(condId: sce.UID, threadId: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Set an event flag bit pattern.
|
||||
*
|
||||
* @param evid - The event id returned by ::sceKernelCreateEventFlag.
|
||||
* @param bits - The bit pattern to set.
|
||||
*
|
||||
* @return < 0 On error
|
||||
*/
|
||||
SetEventFlag :: proc(evid: sce.UID, bits: c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Clear a event flag bit pattern
|
||||
*
|
||||
* @param evid - The event id returned by ::sceKernelCreateEventFlag
|
||||
* @param bits - The bits to clean
|
||||
*
|
||||
* @return < 0 on Error
|
||||
*/
|
||||
ClearEventFlag :: proc(evid: sce.UID, bits: c.uint) -> c.int ---
|
||||
|
||||
/**
|
||||
* Delete an event flag
|
||||
*
|
||||
* @param evid - The event id returned by ::sceKernelCreateEventFlag.
|
||||
*
|
||||
* @return < 0 On error
|
||||
*/
|
||||
DeleteEventFlag :: proc(evid: c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Delete a message pipe
|
||||
*
|
||||
* @param uid - The UID of the pipe
|
||||
*
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
DeleteMsgPipe :: proc(uid: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Destroy a mutex
|
||||
*
|
||||
* @param mutexid - The mutex id returned from ::sceKernelCreateMutex
|
||||
* @return Returns the value 0 if it's successful, otherwise -1
|
||||
*/
|
||||
DeleteMutex :: proc(mutexid: sce.UID) -> c.int ---
|
||||
|
||||
|
||||
/**
|
||||
* Open a mutex
|
||||
*
|
||||
* @param name - The name of the mutex to open
|
||||
* @return Returns the value 0 if it's successful, otherwise -1
|
||||
*/
|
||||
OpenMutex :: proc(name: cstring) -> c.int ---
|
||||
|
||||
/**
|
||||
* Close a mutex
|
||||
*
|
||||
* @param mutexid - The mutex id returned from ::sceKernelCreateMutex
|
||||
* @return Returns the value 0 if it's successful, otherwise -1
|
||||
*/
|
||||
CloseMutex :: proc(mutexid: sce.UID) -> c.int ---
|
||||
|
||||
|
||||
/**
|
||||
* Try to lock a mutex (non-blocking)
|
||||
*
|
||||
* @param mutexid - The mutex id returned from ::sceKernelCreateMutex
|
||||
* @param lockCount - The value to increment to the lock count of the mutex
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
TryLockMutex :: proc(mutexid: sce.UID, lockCount: c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Try to unlock a mutex (non-blocking)
|
||||
*
|
||||
* @param mutexid - The mutex id returned from ::sceKernelCreateMutex
|
||||
* @param unlockCount - The value to decrement to the lock count of the mutex
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
UnlockMutex :: proc(mutexid: sce.UID, unlockCount: c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Destroy a rwlock
|
||||
*
|
||||
* @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
DeleteRWLock :: proc(rwlock_id: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Open a rwlock
|
||||
*
|
||||
* @param name - The name of the rwlock to open
|
||||
* @return RWLock id on success, < 0 on error
|
||||
*/
|
||||
OpenRWLock :: proc(name: cstring) -> sce.UID ---
|
||||
|
||||
/**
|
||||
* Close a rwlock
|
||||
*
|
||||
* @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
CloseRWLock :: proc(rwlock_id: sce.UID) -> c.int ---
|
||||
/**
|
||||
* Try to lock a rwlock with read access (non-blocking)
|
||||
*
|
||||
* @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
TryLockReadRWLock :: proc(rwlock_id: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Try to lock a rwlock with write access (non-blocking)
|
||||
*
|
||||
* @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
TryLockWriteRWLock :: proc(rwlock_id: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Try to unlock a rwlock with read access (non-blocking)
|
||||
*
|
||||
* @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
UnlockReadRWLock :: proc(rwlock_id: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Try to unlock a rwlock with write access (non-blocking)
|
||||
*
|
||||
* @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
UnlockWriteRWLock :: proc(rwlock_id: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Destroy a semaphore
|
||||
*
|
||||
* @param semaid - The semaid returned from a previous create call.
|
||||
* @return Returns the value 0 if it's successful, otherwise -1
|
||||
*/
|
||||
DeleteSema :: proc(semaid: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Send a signal to a semaphore
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* // Signal the sema
|
||||
* sceKernelSignalSema(semaid, 1)
|
||||
* @endcode
|
||||
*
|
||||
* @param semaid - The sema id returned from ::sceKernelCreateSema
|
||||
* @param signal - The amount to signal the sema (i.e. if 2 then increment the sema by 2)
|
||||
*
|
||||
* @return < 0 On error.
|
||||
*/
|
||||
SignalSema :: proc(semaid: sce.UID, signal: c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Poll a semaphore.
|
||||
*
|
||||
* @param semaid - UID of the semaphore to poll.
|
||||
* @param signal - The value to test for.
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
PollSema :: proc(semaid: sce.UID, signal: c.int) -> c.int ---
|
||||
|
||||
OpenSema :: proc(name: cstring) -> sce.UID ---
|
||||
|
||||
CloseSema :: proc(semaid: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* @brief Send a signal to the thread specified by thid. Note that it can send a signal to the current thread as well.
|
||||
*
|
||||
* @param thid - the id of the thread to send a signal to
|
||||
* @return 0 on success
|
||||
* @return SCE_KERNEL_ERROR_ALREADY_SENT if the last signal was not consumed by sceKernelWaitSignal
|
||||
*/
|
||||
SendSignal :: proc(thid: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Delate a thread
|
||||
*
|
||||
* @param thid - UID of the thread to be deleted.
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
DeleteThread :: proc(thid: sce.UID) -> c.int ---
|
||||
|
||||
|
||||
/**
|
||||
* Exit a thread
|
||||
*
|
||||
* @param status - Exit status.
|
||||
*/
|
||||
ExitThread :: proc(status: c.int) -> c.int ---
|
||||
|
||||
|
||||
/**
|
||||
* Exit a thread and delete itself.
|
||||
*
|
||||
* @param status - Exit status
|
||||
*/
|
||||
ExitDeleteThread :: proc(status: c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Delay the current thread by a specified number of microseconds
|
||||
*
|
||||
* @param delay - Delay in microseconds.
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* sceKernelDelayThread(1000000) // Delay for a second
|
||||
* @endcode
|
||||
*/
|
||||
DelayThread :: proc(delay: sce.UInt) -> c.int ---
|
||||
|
||||
/**
|
||||
* Delay the current thread by a specified number of microseconds and handle any callbacks.
|
||||
*
|
||||
* @param delay - Delay in microseconds.
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* sceKernelDelayThread(1000000) // Delay for a second
|
||||
* @endcode
|
||||
*/
|
||||
DelayThreadCB :: proc(delay: sce.UInt) -> c.int ---
|
||||
|
||||
/**
|
||||
* Change the threads current priority.
|
||||
*
|
||||
* @param thid - The ID of the thread (from ::sceKernelCreateThread or ::sceKernelGetThreadId)
|
||||
* @param priority - The new priority (the lower the number the higher the priority)
|
||||
*
|
||||
* @par Example:
|
||||
* @code
|
||||
* int thid = sceKernelGetThreadId()
|
||||
* // Change priority of current thread to 16
|
||||
* sceKernelChangeThreadPriority(thid, 16)
|
||||
* @endcode
|
||||
*
|
||||
* @return 0 if successful, otherwise the error code.
|
||||
*/
|
||||
ChangeThreadPriority :: proc(thid: sce.UID, priority: c.int) -> c.int ---
|
||||
|
||||
|
||||
/**
|
||||
* Get the free stack size for a thread.
|
||||
*
|
||||
* @param thid - The thread ID
|
||||
*
|
||||
* @return The free size.
|
||||
*/
|
||||
GetThreadStackFreeSize :: proc(thid: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Retrive the cpu affinity mask of a thread.
|
||||
*
|
||||
* @param thid - UID of the thread to retrieve affinity mask for.
|
||||
*
|
||||
* @return current affinity mask if >= 0, otherwise the error code.
|
||||
*/
|
||||
GetThreadCpuAffinityMask :: proc(thid: sce.UID) -> c.int ---
|
||||
|
||||
/**
|
||||
* Set the cpu affinity mask of a thread.
|
||||
*
|
||||
* @param thid - UID of the thread to retrieve affinity mask for.
|
||||
* @param mask - New cpu affinity mask.
|
||||
*
|
||||
* @return 0 if successful, otherwise the error code.
|
||||
*/
|
||||
ChangeThreadCpuAffinityMask :: proc(thid: sce.UID, mask: c.int) -> c.int ---
|
||||
|
||||
/**
|
||||
* Get the process ID of in the running thread.
|
||||
*
|
||||
* @return process ID of in the running thread
|
||||
*/
|
||||
GetProcessId :: proc() -> sce.UID ---
|
||||
|
||||
/**
|
||||
* Get the type of a Threadmgr uid
|
||||
*
|
||||
* @param uid - The uid to get the type from
|
||||
*
|
||||
* @return The type, < 0 on error
|
||||
*/
|
||||
GetThreadmgrUIDClass :: proc(uid: sce.UID) -> SceKernelIdListType ---
|
||||
|
||||
|
||||
/**
|
||||
* @brief sceKernelGetThreadTLSAddr gets an address to a 4 bytes area of TLS memory for the specified thread
|
||||
* @param thid - The UID of the thread to access TLS
|
||||
* @param key - the TLS keyslot index
|
||||
* @return pointer to TLS memory
|
||||
*/
|
||||
GetThreadTLSAddr :: proc(thid: sce.UID, key: c.int) -> rawptr ---
|
||||
|
||||
|
||||
/**
|
||||
* Get the system time (wide version)
|
||||
*
|
||||
* @return The system time
|
||||
*/
|
||||
GetSystemTimeWide :: proc() -> sce.Int64 ---
|
||||
|
||||
}
|
||||
@@ -0,0 +1,953 @@
|
||||
package kernel
|
||||
|
||||
import "core:c"
|
||||
import sce "../common"
|
||||
|
||||
// TODO: this should be a c.int
|
||||
SceKernelErrorCode :: enum i64 {
|
||||
OK = 0x0,
|
||||
ERROR = 0x80020001,
|
||||
NOT_IMPLEMENTED = 0x80020002,
|
||||
NOSYS = 0x80020003,
|
||||
UNSUP = 0x80020004,
|
||||
INVALID_ARGUMENT = 0x80020005,
|
||||
ILLEGAL_ADDR = 0x80020006,
|
||||
ILLEGAL_ALIGNMENT = 0x80020007,
|
||||
ILLEGAL_PERMISSION = 0x80020008,
|
||||
INVALID_ARGUMENT_SIZE = 0x80020009,
|
||||
INVALID_FLAGS = 0x8002000A,
|
||||
ILLEGAL_SIZE = 0x8002000B,
|
||||
ILLEGAL_TYPE = 0x8002000C,
|
||||
ILLEGAL_PATTERN = 0x8002000D,
|
||||
ILLEGAL_ATTR = 0x8002000E,
|
||||
ILLEGAL_COUNT = 0x8002000F,
|
||||
ILLEGAL_MODE = 0x80020010,
|
||||
ILLEGAL_OPEN_LIMIT = 0x80020011,
|
||||
ONLY_DEVELOPMENT_MODE = 0x80020012,
|
||||
DEBUG_ERROR = 0x80021000,
|
||||
ILLEGAL_DIPSW_NUMBER = 0x80021001,
|
||||
PA_ERROR = 0x80021100,
|
||||
PA_NOT_AVAILABLE = 0x80021101,
|
||||
PA_INVALID_KEY = 0x80021102,
|
||||
PA_KEY_IS_NOT_SHARED = 0x80021103,
|
||||
PA_INVALID_SIGNATURE = 0x80021104,
|
||||
CPU_ERROR = 0x80022000,
|
||||
MMU_ILLEGAL_L1_TYPE = 0x80022001,
|
||||
MMU_L2_INDEX_OVERFLOW = 0x80022002,
|
||||
MMU_L2_SIZE_OVERFLOW = 0x80022003,
|
||||
INVALID_CPU_AFFINITY = 0x80022004,
|
||||
INVALID_MEMORY_ACCESS = 0x80022005,
|
||||
INVALID_MEMORY_ACCESS_PERMISSION = 0x80022006,
|
||||
VA2PA_FAULT = 0x80022007,
|
||||
VA2PA_MAPPED = 0x80022008,
|
||||
VALIDATION_CHECK_FAILED = 0x80022009,
|
||||
SYSMEM_ERROR = 0x80024000,
|
||||
INVALID_PROCESS_CONTEXT = 0x80024001,
|
||||
UID_NAME_TOO_LONG = 0x80024002,
|
||||
VARANGE_IS_NOT_PHYSICAL_CONTINUOUS = 0x80024003,
|
||||
PHYADDR_ERROR = 0x80024100,
|
||||
NO_PHYADDR = 0x80024101,
|
||||
PHYADDR_USED = 0x80024102,
|
||||
PHYADDR_NOT_USED = 0x80024103,
|
||||
NO_IOADDR = 0x80024104,
|
||||
PHYMEM_ERROR = 0x80024300,
|
||||
ILLEGAL_PHYPAGE_STATUS = 0x80024301,
|
||||
NO_FREE_PHYSICAL_PAGE = 0x80024302,
|
||||
NO_FREE_PHYSICAL_PAGE_UNIT = 0x80024303,
|
||||
PHYMEMPART_NOT_EMPTY = 0x80024304,
|
||||
NO_PHYMEMPART_LPDDR2 = 0x80024305,
|
||||
NO_PHYMEMPART_CDRAM = 0x80024306,
|
||||
PHYMEMPART_OUT_OF_INDEX = 0x80024307,
|
||||
CANNOT_GROW_PHYMEMPART = 0x80024308,
|
||||
NO_FREE_PHYSICAL_PAGE_CDRAM = 0x80024309,
|
||||
INVALID_SUBBUDGET_ID = 0x8002430A,
|
||||
FIXEDHEAP_ERROR = 0x80024400,
|
||||
FIXEDHEAP_ILLEGAL_SIZE = 0x80024401,
|
||||
FIXEDHEAP_ILLEGAL_INDEX = 0x80024402,
|
||||
FIXEDHEAP_INDEX_OVERFLOW = 0x80024403,
|
||||
FIXEDHEAP_NO_CHUNK = 0x80024404,
|
||||
UID_ERROR = 0x80024500,
|
||||
INVALID_UID = 0x80024501,
|
||||
SYSMEM_UID_INVALID_ARGUMENT = 0x80024502,
|
||||
SYSMEM_INVALID_UID_RANGE = 0x80024503,
|
||||
SYSMEM_NO_VALID_UID = 0x80024504,
|
||||
SYSMEM_CANNOT_ALLOCATE_UIDENTRY = 0x80024505,
|
||||
NOT_PROCESS_UID = 0x80024506,
|
||||
NOT_KERNEL_UID = 0x80024507,
|
||||
INVALID_UID_CLASS = 0x80024508,
|
||||
INVALID_UID_SUBCLASS = 0x80024509,
|
||||
UID_CANNOT_FIND_BY_NAME = 0x8002450A,
|
||||
UID_NOT_VISIBLE = 0x8002450B,
|
||||
UID_MAX_OPEN = 0x8002450C,
|
||||
UID_RL_OVERFLOW = 0x8002450D,
|
||||
VIRPAGE_ERROR = 0x80024600,
|
||||
ILLEGAL_VIRPAGE_TYPE = 0x80024601,
|
||||
BLOCK_ERROR = 0x80024700,
|
||||
ILLEGAL_BLOCK_ID = 0x80024701,
|
||||
ILLEGAL_BLOCK_TYPE = 0x80024702,
|
||||
BLOCK_IN_USE = 0x80024703,
|
||||
PARTITION_ERROR = 0x80024800,
|
||||
ILLEGAL_PARTITION_ID = 0x80024801,
|
||||
ILLEGAL_PARTITION_INDEX = 0x80024802,
|
||||
NO_L2PAGETABLE = 0x80024803,
|
||||
HEAPLIB_ERROR = 0x80024900,
|
||||
ILLEGAL_HEAP_ID = 0x80024901,
|
||||
OUT_OF_RANG = 0x80024902,
|
||||
HEAPLIB_NOMEM = 0x80024903,
|
||||
HEAPLIB_VERIFY_ERROR = 0x80024904,
|
||||
SYSMEM_ADDRESS_SPACE_ERROR = 0x80024A00,
|
||||
INVALID_ADDRESS_SPACE_ID = 0x80024A01,
|
||||
INVALID_PARTITION_INDEX = 0x80024A02,
|
||||
ADDRESS_SPACE_CANNOT_FIND_PARTITION_BY_ADDR = 0x80024A03,
|
||||
SYSMEM_MEMBLOCK_ERROR = 0x80024B00,
|
||||
ILLEGAL_MEMBLOCK_TYPE = 0x80024B01,
|
||||
ILLEGAL_MEMBLOCK_REMAP_TYPE = 0x80024B02,
|
||||
NOT_PHY_CONT_MEMBLOCK = 0x80024B03,
|
||||
ILLEGAL_MEMBLOCK_CODE = 0x80024B04,
|
||||
ILLEGAL_MEMBLOCK_SIZE = 0x80024B05,
|
||||
ILLEGAL_USERMAP_SIZE = 0x80024B06,
|
||||
MEMBLOCK_TYPE_FOR_KERNEL_PROCESS = 0x80024B07,
|
||||
PROCESS_CANNOT_REMAP_MEMBLOCK = 0x80024B08,
|
||||
MEMBLOCK_RANGE_ERROR = 0x80024B09,
|
||||
MEMBLOCK_TYPE_FOR_UPDATER_OR_SAFEMODE = 0x80024B0A,
|
||||
MEMBLOCK_OVERFLOW = 0x80024B0B,
|
||||
SYSMEM_PHYMEMLOW_ERROR = 0x80024C00,
|
||||
CANNOT_ALLOC_PHYMEMLOW = 0x80024C01,
|
||||
UNKNOWN_PHYMEMLOW_TYPE = 0x80024C02,
|
||||
SYSMEM_BITHEAP_ERROR = 0x80024D00,
|
||||
CANNOT_ALLOC_BITHEAP = 0x80024D01,
|
||||
SYSMEM_NAMEHEAP_ERROR = 0x80024E00,
|
||||
NO_SUCH_NAME = 0x80024E01,
|
||||
DUPLICATE_NAME = 0x80024E02,
|
||||
LOADCORE_ERROR = 0x80025000,
|
||||
ILLEGAL_ELF_HEADER = 0x80025001,
|
||||
ILLEGAL_SELF_HEADER = 0x80025002,
|
||||
EXCPMGR_ERROR = 0x80027000,
|
||||
ILLEGAL_EXCPCODE = 0x80027001,
|
||||
ILLEGAL_EXCPHANDLER = 0x80027002,
|
||||
NOTFOUND_EXCPHANDLER = 0x80027003,
|
||||
CANNOT_RELEASE_EXCPHANDLER = 0x80027004,
|
||||
INTRMGR_ERROR = 0x80027100,
|
||||
ILLEGAL_CONTEXT = 0x80027101,
|
||||
ILLEGAL_INTRCODE = 0x80027102,
|
||||
ILLEGAL_INTRPARAM = 0x80027103,
|
||||
ILLEGAL_INTRPRIORITY = 0x80027104,
|
||||
ILLEGAL_TARGET_CPU = 0x80027105,
|
||||
ILLEGAL_INTRFILTER = 0x80027106,
|
||||
ILLEGAL_INTRTYPE = 0x80027107,
|
||||
ILLEGAL_HANDLER = 0x80027108,
|
||||
FOUND_HANDLER = 0x80027109,
|
||||
NOTFOUND_HANDLER = 0x8002710A,
|
||||
NO_MEMORY = 0x8002710B,
|
||||
DMACMGR_ERROR = 0x80027200,
|
||||
ALREADY_QUEUED = 0x80027201,
|
||||
NOT_QUEUED = 0x80027202,
|
||||
NOT_SETUP = 0x80027203,
|
||||
ON_TRANSFERRING = 0x80027204,
|
||||
NOT_INITIALIZED = 0x80027205,
|
||||
TRANSFERRED = 0x80027206,
|
||||
NOT_UNDER_CONTROL = 0x80027207,
|
||||
CANCELING = 0x80027208,
|
||||
SYSTIMER_ERROR = 0x80027300,
|
||||
NO_FREE_TIMER = 0x80027301,
|
||||
TIMER_NOT_ALLOCATED = 0x80027302,
|
||||
TIMER_COUNTING = 0x80027303,
|
||||
TIMER_STOPPED = 0x80027304,
|
||||
THREADMGR_ERROR = 0x80028000,
|
||||
UNKNOWN_UID = 0x80028001,
|
||||
DIFFERENT_UID_CLASS = 0x80028002,
|
||||
ALREADY_REGISTERED = 0x80028003,
|
||||
CAN_NOT_WAIT = 0x80028004,
|
||||
WAIT_TIMEOUT = 0x80028005,
|
||||
WAIT_DELETE = 0x80028006,
|
||||
WAIT_CANCEL = 0x80028007,
|
||||
THREAD_ERROR = 0x80028020,
|
||||
UNKNOWN_THREAD_ID = 0x80028021,
|
||||
ILLEGAL_THREAD_ID = 0x80028022,
|
||||
ILLEGAL_PRIORITY = 0x80028023,
|
||||
ILLEGAL_STACK_SIZE = 0x80028024,
|
||||
ILLEGAL_CPU_AFFINITY_MASK = 0x80028025,
|
||||
ILLEGAL_THREAD_PARAM_COMBINATION = 0x80028026,
|
||||
DORMANT = 0x80028027,
|
||||
NOT_DORMANT = 0x80028028,
|
||||
RUNNING = 0x80028029,
|
||||
DELETED = 0x8002802A,
|
||||
CAN_NOT_SUSPEND = 0x8002802B,
|
||||
THREAD_STOPPED = 0x8002802C,
|
||||
THREAD_SUSPENDED = 0x8002802D,
|
||||
NOT_SUSPENDED = 0x8002802E,
|
||||
ALREADY_DEBUG_SUSPENDED = 0x8002802F,
|
||||
NOT_DEBUG_SUSPENDED = 0x80028030,
|
||||
CAN_NOT_USE_VFP = 0x80028031,
|
||||
THREAD_EVENT_ERROR = 0x80028060,
|
||||
UNKNOWN_THREAD_EVENT_ID = 0x80028061,
|
||||
KERNEL_TLS_ERROR = 0x80028080,
|
||||
KERNEL_TLS_FULL = 0x80028081,
|
||||
ILLEGAL_KERNEL_TLS_INDEX = 0x80028082,
|
||||
KERNEL_TLS_BUSY = 0x80028083,
|
||||
CALLBACK_ERROR = 0x800280A0,
|
||||
UNKNOWN_CALLBACK_ID = 0x800280A1,
|
||||
NOTIFY_CALLBACK = 0x800280A2,
|
||||
CALLBACK_NOT_REGISTERED = 0x800280A3,
|
||||
ALARM_ERROR = 0x800280C0,
|
||||
UNKNOWN_ALARM_ID = 0x800280C1,
|
||||
ALARM_CAN_NOT_CANCEL = 0x800280C2,
|
||||
EVF_ERROR = 0x800280E0,
|
||||
UNKNOWN_EVF_ID = 0x800280E1,
|
||||
EVF_MULTI = 0x800280E2,
|
||||
EVF_COND = 0x800280E3,
|
||||
SEMA_ERROR = 0x80028100,
|
||||
UNKNOWN_SEMA_ID = 0x80028101,
|
||||
SEMA_ZERO = 0x80028102,
|
||||
SEMA_OVF = 0x80028103,
|
||||
SIGNAL_ERROR = 0x80028120,
|
||||
ALREADY_SENT = 0x80028121,
|
||||
MUTEX_ERROR = 0x80028140,
|
||||
UNKNOWN_MUTEX_ID = 0x80028141,
|
||||
MUTEX_RECURSIVE = 0x80028142,
|
||||
MUTEX_LOCK_OVF = 0x80028143,
|
||||
MUTEX_UNLOCK_UDF = 0x80028144,
|
||||
MUTEX_FAILED_TO_OWN = 0x80028145,
|
||||
MUTEX_NOT_OWNED = 0x80028146,
|
||||
FAST_MUTEX_ERROR = 0x80028160,
|
||||
UNKNOWN_FAST_MUTEX_ID = 0x80028161,
|
||||
FAST_MUTEX_RECURSIVE = 0x80028162,
|
||||
FAST_MUTEX_LOCK_OVF = 0x80028163,
|
||||
FAST_MUTEX_FAILED_TO_OWN = 0x80028164,
|
||||
FAST_MUTEX_NOT_OWNED = 0x80028165,
|
||||
FAST_MUTEX_OWNED = 0x80028166,
|
||||
FAST_MUTEX_ALREADY_INITIALIZED = 0x80028167,
|
||||
FAST_MUTEX_NOT_INITIALIZED = 0x80028168,
|
||||
LW_MUTEX_ERROR = 0x80028180,
|
||||
UNKNOWN_LW_MUTEX_ID = 0x80028181,
|
||||
LW_MUTEX_RECURSIVE = 0x80028182,
|
||||
LW_MUTEX_LOCK_OVF = 0x80028183,
|
||||
LW_MUTEX_UNLOCK_UDF = 0x80028184,
|
||||
LW_MUTEX_FAILED_TO_OWN = 0x80028185,
|
||||
LW_MUTEX_NOT_OWNED = 0x80028186,
|
||||
COND_ERROR = 0x800281A0,
|
||||
UNKNOWN_COND_ID = 0x800281A1,
|
||||
WAIT_DELETE_MUTEX = 0x800281A2,
|
||||
WAIT_CANCEL_MUTEX = 0x800281A3,
|
||||
WAIT_DELETE_COND = 0x800281A4,
|
||||
WAIT_CANCEL_COND = 0x800281A5,
|
||||
LW_COND_ERROR = 0x800281C0,
|
||||
UNKNOWN_LW_COND_ID = 0x800281C1,
|
||||
WAIT_DELETE_LW_MUTEX = 0x800281C2,
|
||||
WAIT_DELETE_LW_COND = 0x800281C3,
|
||||
RW_LOCK_ERROR = 0x800281E0,
|
||||
UNKNOWN_RW_LOCK_ID = 0x800281E1,
|
||||
RW_LOCK_RECURSIVE = 0x800281E2,
|
||||
RW_LOCK_LOCK_OVF = 0x800281E3,
|
||||
RW_LOCK_NOT_OWNED = 0x800281E4,
|
||||
RW_LOCK_UNLOCK_UDF = 0x800281E5,
|
||||
RW_LOCK_FAILED_TO_LOCK = 0x800281E6,
|
||||
RW_LOCK_FAILED_TO_UNLOCK = 0x800281E7,
|
||||
EVENT_ERROR = 0x80028200,
|
||||
UNKNOWN_EVENT_ID = 0x80028201,
|
||||
EVENT_COND = 0x80028202,
|
||||
MSG_PIPE_ERROR = 0x80028220,
|
||||
UNKNOWN_MSG_PIPE_ID = 0x80028221,
|
||||
MSG_PIPE_FULL = 0x80028222,
|
||||
MSG_PIPE_EMPTY = 0x80028223,
|
||||
MSG_PIPE_DELETED = 0x80028224,
|
||||
TIMER_ERROR = 0x80028240,
|
||||
UNKNOWN_TIMER_ID = 0x80028241,
|
||||
EVENT_NOT_SET = 0x80028242,
|
||||
SIMPLE_EVENT_ERROR = 0x80028260,
|
||||
UNKNOWN_SIMPLE_EVENT_ID = 0x80028261,
|
||||
PMON_ERROR = 0x80028280,
|
||||
PMON_NOT_THREAD_MODE = 0x80028281,
|
||||
PMON_NOT_CPU_MODE = 0x80028282,
|
||||
WORK_QUEUE = 0x80028300,
|
||||
UNKNOWN_WORK_QUEUE_ID = 0x80028301,
|
||||
UNKNOWN_WORK_TASK_ID = 0x80028302,
|
||||
PROCESSMGR_ERROR = 0x80029000,
|
||||
INVALID_PID = 0x80029001,
|
||||
INVALID_PROCESS_TYPE = 0x80029002,
|
||||
PLS_FULL = 0x80029003,
|
||||
INVALID_PROCESS_STATUS = 0x80029004,
|
||||
PROCESS_CALLBACK_NOTFOUND = 0x80029005,
|
||||
INVALID_BUDGET_ID = 0x80029006,
|
||||
INVALID_BUDGET_SIZE = 0x80029007,
|
||||
CP14_DISABLED = 0x80029008,
|
||||
EXCEEDED_MAX_PROCESSES = 0x80029009,
|
||||
PROCESS_REMAINING = 0x8002900A,
|
||||
NO_PROCESS_DATA = 0x8002900B,
|
||||
PROCESS_EVENT_INHIBITED = 0x8002900C,
|
||||
IOFILEMGR_ERROR = 0x8002A000,
|
||||
IO_NAME_TOO_LONG = 0x8002A001,
|
||||
IO_REG_DEV = 0x8002A002,
|
||||
IO_ALIAS_USED = 0x8002A003,
|
||||
IO_DEL_DEV = 0x8002A004,
|
||||
IO_WOULD_BLOCK = 0x8002A005,
|
||||
MODULEMGR_START_FAILED = 0x8002D000,
|
||||
MODULEMGR_STOP_FAIL = 0x8002D001,
|
||||
MODULEMGR_IN_USE = 0x8002D002,
|
||||
MODULEMGR_NO_LIB = 0x8002D003,
|
||||
MODULEMGR_SYSCALL_REG = 0x8002D004,
|
||||
MODULEMGR_NOMEM_LIB = 0x8002D005,
|
||||
MODULEMGR_NOMEM_STUB = 0x8002D006,
|
||||
MODULEMGR_NOMEM_SELF = 0x8002D007,
|
||||
MODULEMGR_NOMEM = 0x8002D008,
|
||||
MODULEMGR_INVALID_LIB = 0x8002D009,
|
||||
MODULEMGR_INVALID_STUB = 0x8002D00A,
|
||||
MODULEMGR_NO_FUNC_NID = 0x8002D00B,
|
||||
MODULEMGR_NO_VAR_NID = 0x8002D00C,
|
||||
MODULEMGR_INVALID_TYPE = 0x8002D00D,
|
||||
MODULEMGR_NO_MOD_ENTRY = 0x8002D00E,
|
||||
MODULEMGR_INVALID_PROC_PARAM = 0x8002D00F,
|
||||
MODULEMGR_NO_MODOBJ = 0x8002D010,
|
||||
MODULEMGR_NO_MOD = 0x8002D011,
|
||||
MODULEMGR_NO_PROCESS = 0x8002D012,
|
||||
MODULEMGR_OLD_LIB = 0x8002D013,
|
||||
MODULEMGR_STARTED = 0x8002D014,
|
||||
MODULEMGR_NOT_STARTED = 0x8002D015,
|
||||
MODULEMGR_NOT_STOPPED = 0x8002D016,
|
||||
MODULEMGR_INVALID_PROCESS_UID = 0x8002D017,
|
||||
MODULEMGR_CANNOT_EXPORT_LIB_TO_SHARED = 0x8002D018,
|
||||
MODULEMGR_INVALID_REL_INFO = 0x8002D019,
|
||||
MODULEMGR_INVALID_REF_INFO = 0x8002D01A,
|
||||
MODULEMGR_ELINK = 0x8002D01B,
|
||||
MODULEMGR_NOENT = 0x8002D01C,
|
||||
MODULEMGR_BUSY = 0x8002D01D,
|
||||
MODULEMGR_NOEXEC = 0x8002D01E,
|
||||
MODULEMGR_NAMETOOLONG = 0x8002D01F,
|
||||
LIBRARYDB_NOENT = 0x8002D080,
|
||||
LIBRARYDB_NO_LIB = 0x8002D081,
|
||||
LIBRARYDB_NO_MOD = 0x8002D082,
|
||||
PRELOAD_FAILED = 0x8002D0F0,
|
||||
PRELOAD_LIBC_FAILED = 0x8002D0F1,
|
||||
PRELOAD_FIOS2_FAILED = 0x8002D0F2,
|
||||
AUTHFAIL = 0x8002F000,
|
||||
NO_AUTH = 0x8002F001
|
||||
}
|
||||
|
||||
SceKernelOpenPsId :: struct {
|
||||
id: [16]c.char,
|
||||
}
|
||||
#assert(size_of(SceKernelOpenPsId) == 0x10)
|
||||
|
||||
/** Threadmgr types */
|
||||
SceKernelIdListType :: enum c.int {
|
||||
SCE_KERNEL_TMID_Thread = 1,
|
||||
SCE_KERNEL_TMID_Semaphore = 2,
|
||||
SCE_KERNEL_TMID_EventFlag = 3,
|
||||
SCE_KERNEL_TMID_Mbox = 4,
|
||||
SCE_KERNEL_TMID_Vpl = 5,
|
||||
SCE_KERNEL_TMID_Fpl = 6,
|
||||
SCE_KERNEL_TMID_Mpipe = 7,
|
||||
SCE_KERNEL_TMID_Callback = 8,
|
||||
SCE_KERNEL_TMID_ThreadEventHandler = 9,
|
||||
SCE_KERNEL_TMID_Alarm = 10,
|
||||
SCE_KERNEL_TMID_VTimer = 11,
|
||||
SCE_KERNEL_TMID_SleepThread = 64,
|
||||
SCE_KERNEL_TMID_DelayThread = 65,
|
||||
SCE_KERNEL_TMID_SuspendThread = 66,
|
||||
SCE_KERNEL_TMID_DormantThread = 67,
|
||||
}
|
||||
|
||||
SceThreadStatus :: enum c.int {
|
||||
RUNNING = 1,
|
||||
READY = 2,
|
||||
STANDBY = 4,
|
||||
WAITING = 8,
|
||||
SUSPEND = 8, /* Compatibility */
|
||||
DORMANT = 16,
|
||||
STOPPED = 16, /* Compatibility */
|
||||
DELETED = 32, /* Thread manager has killed the thread (stack overflow) */
|
||||
KILLED = 32, /* Compatibility */
|
||||
DEAD = 64,
|
||||
STAGNANT = 128,
|
||||
SUSPENDED = 256,
|
||||
}
|
||||
|
||||
/** Statistics about a running thread.
|
||||
* @see sceKernelGetThreadRunStatus.
|
||||
*/
|
||||
SceKernelThreadRunStatus :: struct {
|
||||
size: sce.Size,
|
||||
cpuInfo: [4]struct {
|
||||
processId: sce.UID,
|
||||
threadId: sce.UID,
|
||||
priority: c.int,
|
||||
},
|
||||
}
|
||||
#assert(size_of(SceKernelThreadRunStatus) == 0x34)
|
||||
|
||||
SceKernelThreadEntry :: #type ^proc(args: sce.Size, argp: rawptr) -> c.int
|
||||
|
||||
/** Additional options used when creating threads. */
|
||||
SceKernelThreadOptParam :: struct {
|
||||
/** Size of the ::SceKernelThreadOptParam structure. */
|
||||
size: sce.Size,
|
||||
/** Attributes */
|
||||
attr: sce.UInt32,
|
||||
kStackMemType: sce.UInt32,
|
||||
uStackMemType: sce.UInt32,
|
||||
uTLSMemType: sce.UInt32,
|
||||
uStackMemid: sce.UInt32,
|
||||
data_0x18: sce.UInt32,
|
||||
}
|
||||
#assert(size_of(SceKernelThreadOptParam) == 0x1C)
|
||||
|
||||
/** Structure to hold the status information for a thread
|
||||
* @see sceKernelGetThreadInfo
|
||||
*/
|
||||
SceKernelThreadInfo :: struct {
|
||||
/** Size of the structure */
|
||||
size: sce.Size,
|
||||
/** The UID of the process where the thread belongs */
|
||||
processId: sce.UID,
|
||||
/** Nul terminated name of the thread */
|
||||
name: [32]c.char,
|
||||
/** Thread attributes */
|
||||
attr: sce.UInt32,
|
||||
/** Thread status */
|
||||
status: sce.UInt32,
|
||||
/** Thread entry point */
|
||||
entry: SceKernelThreadEntry,
|
||||
/** Thread stack pointer */
|
||||
stack: rawptr,
|
||||
/** Thread stack size */
|
||||
stackSize: sce.Int32,
|
||||
/** Initial priority */
|
||||
initPriority: sce.Int32,
|
||||
/** Current priority */
|
||||
currentPriority: sce.Int32,
|
||||
/** Initial CPU affinity mask */
|
||||
initCpuAffinityMask: sce.Int32,
|
||||
/** Current CPU affinity mask */
|
||||
currentCpuAffinityMask: sce.Int32,
|
||||
/** Current CPU ID */
|
||||
currentCpuId: sce.Int32,
|
||||
/** Last executed CPU ID */
|
||||
lastExecutedCpuId: sce.Int32,
|
||||
/** Wait type */
|
||||
waitType: sce.UInt32,
|
||||
/** Wait id */
|
||||
waitId: sce.UID,
|
||||
/** Exit status of the thread */
|
||||
exitStatus: sce.Int32,
|
||||
/** Number of clock cycles run */
|
||||
runClocks: sce.KernelSysClock,
|
||||
/** Interrupt preemption count */
|
||||
intrPreemptCount: sce.UInt32,
|
||||
/** Thread preemption count */
|
||||
threadPreemptCount: sce.UInt32,
|
||||
/** Thread release count */
|
||||
threadReleaseCount: sce.UInt32,
|
||||
/** Number of CPUs to which the thread is moved */
|
||||
changeCpuCount: sce.Int32,
|
||||
/** Function notify callback UID */
|
||||
fNotifyCallback: sce.Int32,
|
||||
/** Reserved */
|
||||
reserved: sce.Int32,
|
||||
}
|
||||
when size_of(rawptr) == 4 {
|
||||
#assert(size_of(SceKernelThreadInfo) == 0x80)
|
||||
}
|
||||
|
||||
/** Inherit calling thread affinity mask. */
|
||||
SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT :: 0
|
||||
|
||||
|
||||
|
||||
/** Callback function prototype */
|
||||
SceKernelCallbackFunction :: #type ^proc(notifyId: c.int, notifyCount: c.int, notifyArg: c.int, userData: rawptr) -> c.int
|
||||
|
||||
/** Structure to hold the status information for a callback */
|
||||
SceKernelCallbackInfo :: struct {
|
||||
/** Size of the structure (i.e. sizeof(SceKernelCallbackInfo)) */
|
||||
size: sce.Size,
|
||||
/** The UID of the callback. */
|
||||
callbackId: sce.UID, // Needs confirmation
|
||||
/** The name given to the callback */
|
||||
name: [32]c.char,
|
||||
/** The thread id associated with the callback */
|
||||
threadId: sce.UID,
|
||||
/** Pointer to the callback function */
|
||||
callback: SceKernelCallbackFunction,
|
||||
/** User supplied argument for the callback */
|
||||
common: rawptr,
|
||||
/** Unknown */
|
||||
notifyCount: c.int,
|
||||
/** Unknown */
|
||||
notifyArg: c.int,
|
||||
}
|
||||
when size_of(rawptr) == 4 {
|
||||
#assert(size_of(SceKernelCallbackInfo) == 0x3C)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** Additional options used when creating semaphores. */
|
||||
SceKernelSemaOptParam :: struct {
|
||||
/** Size of the ::SceKernelSemaOptParam structure. */
|
||||
size: sce.Size,
|
||||
}
|
||||
#assert(size_of(SceKernelSemaOptParam) == 4)
|
||||
|
||||
/** Current state of a semaphore.
|
||||
* @see sceKernelGetSemaInfo.
|
||||
*/
|
||||
SceKernelSemaInfo :: struct {
|
||||
/** Size of the ::SceKernelSemaInfo structure. */
|
||||
size: sce.Size,
|
||||
/** The UID of the semaphore */
|
||||
semaId: sce.UID,
|
||||
/** NUL-terminated name of the semaphore. */
|
||||
name: [32]c.char,
|
||||
/** Attributes. */
|
||||
attr: sce.UInt,
|
||||
/** The initial count the semaphore was created with. */
|
||||
initCount: c.int,
|
||||
/** The current count. */
|
||||
currentCount: c.int,
|
||||
/** The maximum count. */
|
||||
maxCount: c.int,
|
||||
/** The number of threads waiting on the semaphore. */
|
||||
numWaitThreads: c.int,
|
||||
}
|
||||
#assert(size_of(SceKernelSemaInfo) == 0x3C)
|
||||
|
||||
|
||||
|
||||
SceKernelWaitableAttribute :: enum c.int {
|
||||
THREAD_FIFO = 0x00000000, //!< Waiting threads First input First output
|
||||
THREAD_PRIO = 0x00002000, //!< Waiting threads queued on priority basis
|
||||
OPENABLE = 0x00000080, //!< Sync object can be accessed by sceKernelOpenXxx
|
||||
}
|
||||
|
||||
/** Event flag creation attributes */
|
||||
SceEventFlagAttributes :: enum c.int {
|
||||
// Deprecated
|
||||
THREAD_FIFO = auto_cast SceKernelWaitableAttribute.THREAD_FIFO, //!< Use SCE_KERNEL_ATTR_THREAD_FIFO
|
||||
// Deprecated
|
||||
THREAD_PRIO = auto_cast SceKernelWaitableAttribute.THREAD_PRIO, //!< Use SCE_KERNEL_ATTR_THREAD_PRIO
|
||||
WAITSINGLE = 0, //!< Sync object can only be waited upon by one thread.
|
||||
WAITMULTIPLE = 0x00001000, //!< Sync object can be waited upon by multiple threads.
|
||||
// Deprecated
|
||||
OPENABLE = auto_cast SceKernelWaitableAttribute.OPENABLE, //!< Use SCE_KERNEL_ATTR_OPENABLE
|
||||
}
|
||||
|
||||
SceKernelEventFlagOptParam :: struct {
|
||||
size: sce.Size,
|
||||
}
|
||||
#assert(size_of(SceKernelEventFlagOptParam) == 4)
|
||||
|
||||
/** Structure to hold the event flag information */
|
||||
SceKernelEventFlagInfo :: struct {
|
||||
size: sce.Size,
|
||||
evfId: sce.UID, // Needs confirmation
|
||||
name: [32]c.char,
|
||||
attr: sce.UInt,
|
||||
initPattern: sce.UInt,
|
||||
currentPattern: sce.UInt,
|
||||
numWaitThreads: c.int,
|
||||
}
|
||||
#assert(size_of(SceKernelEventFlagInfo) == 0x38)
|
||||
|
||||
/** Event flag wait types */
|
||||
SceEventFlagWaitTypes :: enum c.int {
|
||||
/** Wait for all bits in the pattern to be set */
|
||||
WAITAND = 0,
|
||||
/** Wait for one or more bits in the pattern to be set */
|
||||
WAITOR = 1,
|
||||
/** Clear all the bits when it matches */
|
||||
WAITCLEAR = 2,
|
||||
/** Clear the wait pattern when it matches */
|
||||
WAITCLEAR_PAT = 4,
|
||||
}
|
||||
|
||||
|
||||
|
||||
SceKernelLwCondWork :: struct {
|
||||
data: [4]sce.Int32 ,
|
||||
}
|
||||
#assert(size_of(SceKernelLwCondWork) == 0x10)
|
||||
|
||||
SceKernelLwCondOptParam :: struct {
|
||||
size: sce.Size,
|
||||
}
|
||||
#assert(size_of(SceKernelLwCondOptParam) == 4)
|
||||
|
||||
|
||||
|
||||
SceKernelLwMutexWork :: struct {
|
||||
data: [4]sce.Int64,
|
||||
}
|
||||
#assert(size_of(SceKernelLwMutexWork) == 0x20)
|
||||
|
||||
SceKernelLwMutexOptParam :: struct {
|
||||
size: sce.Size,
|
||||
}
|
||||
#assert(size_of(SceKernelLwMutexOptParam) == 4)
|
||||
|
||||
|
||||
|
||||
|
||||
SceKernelMutexAttribute :: enum c.int {
|
||||
RECURSIVE = 0x02,
|
||||
CEILING = 0x04,
|
||||
}
|
||||
|
||||
/** Additional options used when creating mutexes. */
|
||||
SceKernelMutexOptParam :: struct {
|
||||
/** Size of the ::SceKernelMutexOptParam structure. */
|
||||
size: sce.Size,
|
||||
ceilingPriority: c.int,
|
||||
}
|
||||
#assert(size_of(SceKernelMutexOptParam) == 8)
|
||||
|
||||
/** Current state of a mutex.
|
||||
* @see sceKernelGetMutexInfo.
|
||||
*/
|
||||
SceKernelMutexInfo :: struct {
|
||||
/** Size of the ::SceKernelMutexInfo structure. */
|
||||
size: sce.Size,
|
||||
/** The UID of the mutex. */
|
||||
mutexId: sce.UID,
|
||||
/** NUL-terminated name of the mutex. */
|
||||
name: [32]c.char,
|
||||
/** Attributes. */
|
||||
attr: sce.UInt,
|
||||
/** The initial count the mutex was created with. */
|
||||
initCount: c.int,
|
||||
/** The current count. */
|
||||
currentCount: c.int,
|
||||
/** The UID of the current owner of the mutex. */
|
||||
currentOwnerId: sce.UID,
|
||||
/** The number of threads waiting on the mutex. */
|
||||
numWaitThreads: c.int,
|
||||
}
|
||||
#assert(size_of(SceKernelMutexInfo) == 0x3C)
|
||||
|
||||
|
||||
|
||||
/** Additional options used when creating condition variables. */
|
||||
SceKernelCondOptParam :: struct {
|
||||
/** Size of the ::SceKernelCondOptParam structure. */
|
||||
size: sce.Size,
|
||||
}
|
||||
#assert(size_of(SceKernelCondOptParam) == 4)
|
||||
|
||||
/** Current state of a condition variable.
|
||||
* @see sceKernelGetCondInfo.
|
||||
*/
|
||||
SceKernelCondInfo :: struct {
|
||||
/** Size of the ::SceKernelCondInfo structure. */
|
||||
size: sce.Size,
|
||||
/** The UID of the condition variable. */
|
||||
condId: sce.UID,
|
||||
/** NUL-terminated name of the condition variable. */
|
||||
name: [32]c.char,
|
||||
/** Attributes. */
|
||||
attr: sce.UInt,
|
||||
/** Mutex associated with the condition variable. */
|
||||
mutexId: sce.UID,
|
||||
/** The number of threads waiting on the condition variable. */
|
||||
numWaitThreads: c.int,
|
||||
}
|
||||
#assert(size_of(SceKernelCondInfo) == 0x34)
|
||||
|
||||
//
|
||||
// modulemgr.h start
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief Return values for plugins `module_start` and `module_stop`
|
||||
*/
|
||||
/** @{ */
|
||||
SCE_KERNEL_START_SUCCESS :: (0)
|
||||
SCE_KERNEL_START_RESIDENT :: SCE_KERNEL_START_SUCCESS
|
||||
SCE_KERNEL_START_NO_RESIDENT :: (1)
|
||||
SCE_KERNEL_START_FAILED :: (2)
|
||||
|
||||
SCE_KERNEL_STOP_SUCCESS :: (0)
|
||||
SCE_KERNEL_STOP_FAIL :: (1)
|
||||
SCE_KERNEL_STOP_CANCEL :: SCE_KERNEL_STOP_FAIL
|
||||
/** @} */
|
||||
|
||||
SceKernelModuleState :: enum c.int {
|
||||
READY = 0x00000002,
|
||||
STARTED = 0x00000006,
|
||||
ENDED = 0x00000009
|
||||
}
|
||||
|
||||
/*
|
||||
* Assigning the following macro to the variable sceKernelPreloadModuleInhibit with the OR operator inhibit preloading that module.
|
||||
*
|
||||
* Example
|
||||
* <code>
|
||||
* // Inhibit preload SceLibc and SceShellSvc.
|
||||
* int sceKernelPreloadModuleInhibit = SCE_KERNEL_PRELOAD_INHIBIT_LIBC | SCE_KERNEL_PRELOAD_INHIBIT_LIBSHELLSVC;
|
||||
* </code>
|
||||
*
|
||||
* And these are only valid for modules in the process image, preload is not inhibited even if specified for modules to be loaded later.
|
||||
*
|
||||
* WARNING
|
||||
* If SceLibNet etc. is loaded without SceShellSvc etc. loaded, an unintended system crash will occur.
|
||||
*/
|
||||
SceKernelPreloadInhibit :: enum c.int {
|
||||
NONE = 0x00000000,
|
||||
LIBC = 0x10000,
|
||||
LIBDBG = 0x20000,
|
||||
LIBSHELLSVC = 0x80000,
|
||||
LIBCDLG = 0x100000,
|
||||
LIBFIOS2 = 0x200000,
|
||||
APPUTIL = 0x400000,
|
||||
LIBSCEFT2 = 0x800000,
|
||||
LIBPVF = 0x1000000,
|
||||
LIBPERF = 0x2000000
|
||||
}
|
||||
#assert(size_of(SceKernelPreloadInhibit) == 4)
|
||||
|
||||
|
||||
SceKernelSegmentInfo :: struct {
|
||||
size: sce.Size, //!< this structure size (0x18)
|
||||
perms: sce.UInt, //!< probably rwx in low bits
|
||||
vaddr: rawptr, //!< address in memory
|
||||
memsz: sce.Size, //!< size in memory
|
||||
filesz: sce.Size, //!< original size of memsz
|
||||
res: sce.UInt, //!< unused
|
||||
}
|
||||
when size_of(rawptr) == 4 {
|
||||
#assert(size_of(SceKernelSegmentInfo) == 0x18)
|
||||
}
|
||||
|
||||
SceKernelModuleInfo :: struct {
|
||||
size: sce.Size, //!< 0x1B8 for Vita 1.x
|
||||
modid: sce.UID,
|
||||
modattr: c.uint16_t,
|
||||
modver: [2]c.uint8_t,
|
||||
module_name: [28]c.char,
|
||||
unk28: sce.UInt,
|
||||
start_entry: rawptr,
|
||||
stop_entry: rawptr,
|
||||
exit_entry: rawptr,
|
||||
exidx_top: rawptr,
|
||||
exidx_btm: rawptr,
|
||||
extab_top: rawptr,
|
||||
extab_btm: rawptr,
|
||||
tlsInit: rawptr,
|
||||
tlsInitSize: sce.Size,
|
||||
tlsAreaSize: sce.Size,
|
||||
path: [256]c.char,
|
||||
segments: [4]SceKernelSegmentInfo,
|
||||
state: sce.UInt, //!< see:SceKernelModuleState
|
||||
}
|
||||
when size_of(rawptr) == 4 {
|
||||
#assert(size_of(SceKernelModuleInfo) == 0x1B8)
|
||||
}
|
||||
|
||||
SceKernelLMOption :: struct {
|
||||
size: sce.Size,
|
||||
}
|
||||
#assert(size_of(SceKernelLMOption) == 4)
|
||||
|
||||
SceKernelULMOption :: struct {
|
||||
size: sce.Size,
|
||||
}
|
||||
#assert(size_of(SceKernelULMOption) == 4)
|
||||
|
||||
SceKernelSystemSwVersion :: struct {
|
||||
size: sce.Size,
|
||||
versionString: [0x1C]c.char,
|
||||
version: sce.UInt,
|
||||
unk_24: sce.UInt,
|
||||
}
|
||||
#assert(size_of(SceKernelSystemSwVersion) == 0x28)
|
||||
|
||||
/* For backward compatibility */
|
||||
SceKernelFwInfo :: SceKernelSystemSwVersion
|
||||
|
||||
SceKernelModuleLibraryInfo :: struct {
|
||||
size: sce.Size, //!< sizeof(SceKernelModuleLibraryInfo) : 0x120
|
||||
library_id: sce.UID,
|
||||
libnid: c.uint32_t,
|
||||
version: c.uint16_t,
|
||||
flags: c.uint16_t,
|
||||
entry_num_function: c.uint16_t,
|
||||
entry_num_variable: c.uint16_t,
|
||||
unk_0x14: c.uint16_t,
|
||||
unk_0x16: c.uint16_t,
|
||||
library_name: [0x100]c.char,
|
||||
number_of_imported: sce.Size,
|
||||
modid2: sce.UID,
|
||||
}
|
||||
#assert(size_of(SceKernelModuleLibraryInfo) == 0x120)
|
||||
|
||||
|
||||
//
|
||||
// modulemgr.h end
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// processmgr.h start
|
||||
//
|
||||
|
||||
|
||||
SceKernelProcessType :: distinct sce.UInt32
|
||||
SceKernelClock :: distinct sce.UInt64
|
||||
SceKernelTime :: distinct sce.UInt32
|
||||
|
||||
SceKernelTimeval :: struct {
|
||||
sec: sce.Int32,
|
||||
usec: sce.Int32,
|
||||
}
|
||||
#assert(size_of(SceKernelTimeval) == 8)
|
||||
|
||||
SceKernelTimezone :: struct {
|
||||
value: sce.UInt64,
|
||||
}
|
||||
#assert(size_of(SceKernelTimezone) == 8)
|
||||
|
||||
SceKernelProcessPrioritySystem :: enum c.int {
|
||||
SCE_KERNEL_PROCESS_PRIORITY_SYSTEM_HIGH = 32,
|
||||
SCE_KERNEL_PROCESS_PRIORITY_SYSTEM_DEFAULT = 96,
|
||||
SCE_KERNEL_PROCESS_PRIORITY_SYSTEM_LOW = 159,
|
||||
__SCE_KERNEL_PROCESS_PRIORITY_SYSTEM = -1 // 0xFFFFFFFF
|
||||
}
|
||||
#assert(size_of(SceKernelProcessPrioritySystem) == 4)
|
||||
|
||||
SceKernelProcessPriorityUser :: enum c.int {
|
||||
SCE_KERNEL_PROCESS_PRIORITY_USER_HIGH = 64,
|
||||
SCE_KERNEL_PROCESS_PRIORITY_USER_DEFAULT = 96,
|
||||
SCE_KERNEL_PROCESS_PRIORITY_USER_LOW = 127,
|
||||
__SCE_KERNEL_PROCESS_PRIORITY_USER = -1 // 0xFFFFFFFF
|
||||
}
|
||||
#assert(size_of(SceKernelProcessPriorityUser) == 4)
|
||||
|
||||
SceKernelPowerTickType :: enum c.int {
|
||||
/** Cancel all timers */
|
||||
SCE_KERNEL_POWER_TICK_DEFAULT = 0,
|
||||
/** Cancel automatic suspension timer */
|
||||
SCE_KERNEL_POWER_TICK_DISABLE_AUTO_SUSPEND = 1,
|
||||
/** Cancel OLED-off timer */
|
||||
SCE_KERNEL_POWER_TICK_DISABLE_OLED_OFF = 4,
|
||||
/** Cancel OLED dimming timer */
|
||||
SCE_KERNEL_POWER_TICK_DISABLE_OLED_DIMMING = 6,
|
||||
__SCE_KERNEL_POWER_TICK_DISABLE = -1 // 0xFFFFFFFF
|
||||
}
|
||||
#assert(size_of(SceKernelPowerTickType) == 4)
|
||||
|
||||
|
||||
//
|
||||
// processmgr.h end
|
||||
//
|
||||
|
||||
|
||||
|
||||
//
|
||||
// sysmem.h start
|
||||
//
|
||||
|
||||
SceKernelMemBlockType :: distinct sce.UInt32
|
||||
#assert(size_of(SceKernelMemBlockType) == 4)
|
||||
|
||||
/*
|
||||
* User/Kernel shared memtypes
|
||||
*/
|
||||
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_L1WBWA_RW :: (0x09404060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_R :: (0x09408040)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW :: (0x09408060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_DEVICE_RW :: (0x0C200860)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_R :: (0x0C20D040)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_RW :: (0x0C20D060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_NC_RW :: (0x0C208060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_GAME_RW :: (0x0C50D060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW :: (0x0C80D060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW :: (0x0D808060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_CDIALOG_RW :: (0x0CA0D060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_CDIALOG_NC_RW :: (0x0CA08060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_TOOL_RW :: (0x0CF0D060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_TOOL_NC_RW :: (0x0CF08060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_R :: (0x0E20D040)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RW :: (0x0E20D060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_NC_R :: (0x0E208040)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_NC_RW :: (0x0E208060)
|
||||
|
||||
|
||||
/*
|
||||
* For Backwards compatibility
|
||||
*/
|
||||
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE :: (0x0C208060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW :: (0x0C20D060)
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_TOOL_NC_RW :: (0x0CF08060)
|
||||
|
||||
|
||||
SceKernelAllocMemBlockAttr :: enum c.uint {
|
||||
HAS_PADDR = 0x00000002,
|
||||
HAS_ALIGNMENT = 0x00000004,
|
||||
HAS_MIRROR_BLOCKID = 0x00000040,
|
||||
HAS_PID = 0x00000080,
|
||||
HAS_PADDR_LIST = 0x00001000,
|
||||
PHYCONT = 0x00200000,
|
||||
ALLOW_PARTIAL_OP = 0x04000000,
|
||||
}
|
||||
|
||||
SceKernelModel :: enum c.int {
|
||||
VITA = 0x10000,
|
||||
VITATV = 0x20000
|
||||
}
|
||||
|
||||
SCE_KERNEL_CPU_MASK_USER_0 :: 0x00010000
|
||||
SCE_KERNEL_CPU_MASK_USER_1 :: 0x00020000
|
||||
SCE_KERNEL_CPU_MASK_USER_2 :: 0x00040000
|
||||
SCE_KERNEL_CPU_MASK_SYSTEM :: 0x00080000
|
||||
|
||||
SCE_KERNEL_CPU_MASK_USER_ALL :: (SCE_KERNEL_CPU_MASK_USER_0 | SCE_KERNEL_CPU_MASK_USER_1 | SCE_KERNEL_CPU_MASK_USER_2)
|
||||
|
||||
SceKernelAllocMemBlockOpt :: struct {
|
||||
size: sce.Size,
|
||||
attr: sce.UInt32,
|
||||
alignment: sce.Size,
|
||||
uidBaseBlock: sce.UInt32,
|
||||
strBaseBlockName: cstring,
|
||||
flags: c.int, //! Unknown flags 0x10 or 0x30 for ::sceKernelOpenMemBlock
|
||||
reserved: [10]c.int,
|
||||
}
|
||||
when size_of(rawptr) == 4 {
|
||||
#assert(size_of(SceKernelAllocMemBlockOpt) == 0x40)
|
||||
}
|
||||
|
||||
SceKernelFreeMemorySizeInfo :: struct {
|
||||
size: c.int, //!< sizeof(SceKernelFreeMemorySizeInfo)
|
||||
size_user: c.int, //!< Free memory size for *_USER_RW memory
|
||||
size_cdram: c.int, //!< Free memory size for USER_CDRAM_RW memory
|
||||
size_phycont: c.int, //!< Free memory size for USER_MAIN_PHYCONT_*_RW memory
|
||||
}
|
||||
#assert(size_of(SceKernelFreeMemorySizeInfo) == 0x10)
|
||||
|
||||
SceKernelMemBlockInfo :: struct {
|
||||
size: sce.Size,
|
||||
mappedBase: rawptr,
|
||||
mappedSize: sce.Size,
|
||||
memoryType: c.int,
|
||||
access: sce.UInt32,
|
||||
type: SceKernelMemBlockType,
|
||||
}
|
||||
when size_of(rawptr) == 4 {
|
||||
#assert(size_of(SceKernelMemBlockInfo) == 0x18)
|
||||
}
|
||||
|
||||
SceKernelMemoryAccessType :: enum c.int {
|
||||
SCE_KERNEL_MEMORY_ACCESS_X = 0x01,
|
||||
SCE_KERNEL_MEMORY_ACCESS_W = 0x02,
|
||||
SCE_KERNEL_MEMORY_ACCESS_R = 0x04
|
||||
}
|
||||
|
||||
SceKernelMemoryType :: enum c.int {
|
||||
SCE_KERNEL_MEMORY_TYPE_NORMAL_NC = 0x80,
|
||||
SCE_KERNEL_MEMORY_TYPE_NORMAL = 0xD0
|
||||
}
|
||||
|
||||
//
|
||||
// sysmem.h end
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user