use crate::eabi::i5;
use core::{ffi::c_void, fmt};
mod thread;
pub use thread::*;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SceKernelLoadExecParam {
pub size: usize,
pub args: usize,
pub argp: *mut c_void,
pub key: *const u8,
}
psp_extern! {
#![name = "LoadExecForUser"]
#![flags = 0x4001]
#![version = (0, 0)]
#[psp(0x05572A5F)]
pub fn sceKernelExitGame();
#[psp(0x4AC57943)]
pub fn sceKernelRegisterExitCallback(id: SceUid) -> i32;
#[psp(0xBD2F1094)]
pub fn sceKernelLoadExec(
file: *const u8,
param: *mut SceKernelLoadExecParam,
) -> i32;
}
#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SceUid(pub i32);
impl From<SceUid> for i32 {
fn from(uid: SceUid) -> i32 {
uid.0
}
}
impl From<i32> for SceUid {
fn from(uid: i32) -> SceUid {
SceUid(uid)
}
}
#[repr(i32)]
pub enum SceSysMemPartitionId {
SceKernelUnknownPartition = 0,
SceKernelPrimaryKernelPartition = 1,
SceKernelPrimaryUserPartition = 2,
SceKernelOtherKernelPartition1 = 3, SceKernelOtherKernelPartition2 = 4,
SceKernelVshellPARTITION = 5,
SceKernelScUserPartition = 6,
SceKernelMeUserPartition = 7,
SceKernelExtendedScKernelPartition = 8,
SceKernelExtendedSc2KernelPartition = 9,
SceKernelExtendedMeKernelPartition = 10,
SceKernelVshellKernelPartition = 11,
SceKernelExtendedKernelPartition = 12,
}
#[repr(i32)]
pub enum SceSysMemBlockTypes {
Low = 0,
High,
Addr,
}
psp_extern! {
#![name = "SysMemUserForUser"]
#![flags = 0x4000]
#![version = (0, 0)]
#[psp(0x237DBD4F, i5)]
pub fn sceKernelAllocPartitionMemory(
partition: SceSysMemPartitionId,
name: *const u8,
type_: SceSysMemBlockTypes,
size: u32,
addr: *mut c_void,
) -> SceUid;
#[psp(0x9D9A5BA1)]
pub fn sceKernelGetBlockHeadAddr(blockid: SceUid) -> *mut c_void;
#[psp(0xB6D61D02)]
pub fn sceKernelFreePartitionMemory(blockid: SceUid) -> i32;
#[psp(0xF919F628)]
pub fn sceKernelTotalFreeMemSize() -> usize;
#[psp(0xA291F107)]
pub fn sceKernelMaxFreeMemSize() -> usize;
#[psp(0x3FC9AE6A)]
pub fn sceKernelDevkitVersion() -> u32;
#[psp(0x7591C7DB)]
pub fn sceKernelSetCompiledSdkVersion(version: u32) -> i32;
#[psp(0xFC114573)]
pub fn sceKernelGetCompiledSdkVersion() -> u32;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct timeval {
pub tv_sec: i32,
pub tv_usec: i32,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct timezone {
pub tz_minutes_west: i32,
pub tz_dst_time: i32,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SceKernelUtilsSha1Context {
pub h: [u32; 5usize],
pub us_remains: u16,
pub us_computed: u16,
pub ull_total_len: u64,
pub buf: [u8; 64usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SceKernelUtilsMt19937Context {
pub count: u32,
pub state: [u32; 624usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct SceKernelUtilsMd5Context {
pub h: [u32; 4usize],
pub pad: u32,
pub us_remains: u16,
pub us_computed: u16,
pub ull_total_len: u64,
pub buf: [u8; 64usize],
}
psp_extern! {
#![name = "UtilsForUser"]
#![flags = 0x4001]
#![version = (0x00, 0x00)]
#[psp(0x27CC57F0)]
pub fn sceKernelLibcTime(t: *mut i32) -> i32;
#[psp(0x91E4F6A7)]
pub fn sceKernelLibcClock() -> u32;
#[psp(0x71EC4271)]
pub fn sceKernelLibcGettimeofday(tp: *mut timeval, tzp: *mut timezone) -> i32;
#[psp(0x79D1C3FA)]
pub fn sceKernelDcacheWritebackAll();
#[psp(0xB435DEC5)]
pub fn sceKernelDcacheWritebackInvalidateAll();
#[psp(0x3EE30821)]
pub fn sceKernelDcacheWritebackRange(
p: *const c_void,
size: u32,
);
#[psp(0x34B9FA9E)]
pub fn sceKernelDcacheWritebackInvalidateRange(
p: *const c_void,
size: u32,
);
#[psp(0xBFA98062)]
pub fn sceKernelDcacheInvalidateRange(
p: *const c_void,
size: u32,
);
#[psp(0x920F104A)]
pub fn sceKernelIcacheInvalidateAll();
#[psp(0xC2DF770E)]
pub fn sceKernelIcacheInvalidateRange(
p: *const c_void,
size: u32,
);
#[psp(0xE860E75E)]
pub fn sceKernelUtilsMt19937Init(
ctx: *mut SceKernelUtilsMt19937Context,
seed: u32,
) -> i32;
#[psp(0x06FB8A63)]
pub fn sceKernelUtilsMt19937UInt(ctx: *mut SceKernelUtilsMt19937Context) -> u32;
#[psp(0xC8186A58)]
pub fn sceKernelUtilsMd5Digest(
data: *mut u8,
size: u32,
digest: *mut u8,
) -> i32;
#[psp(0x9E5C5086)]
pub fn sceKernelUtilsMd5BlockInit(ctx: *mut SceKernelUtilsMd5Context) -> i32;
#[psp(0x61E1E525)]
pub fn sceKernelUtilsMd5BlockUpdate(
ctx: *mut SceKernelUtilsMd5Context,
data: *mut u8,
size: u32,
) -> i32;
#[psp(0xB8D24E78)]
pub fn sceKernelUtilsMd5BlockResult(
ctx: *mut SceKernelUtilsMd5Context,
digest: *mut u8,
) -> i32;
#[psp(0x840259F1)]
pub fn sceKernelUtilsSha1Digest(
data: *mut u8,
size: u32,
digest: *mut u8,
) -> i32;
#[psp(0xF8FCD5BA)]
pub fn sceKernelUtilsSha1BlockInit(
ctx: *mut SceKernelUtilsSha1Context,
) -> i32;
#[psp(0x346F6DA8)]
pub fn sceKernelUtilsSha1BlockUpdate(
ctx: *mut SceKernelUtilsSha1Context,
data: *mut u8,
size: u32,
) -> i32;
#[psp(0x585F1C09)]
pub fn sceKernelUtilsSha1BlockResult(
ctx: *mut SceKernelUtilsSha1Context,
digest: *mut u8,
) -> i32;
}
#[repr(packed, C)]
pub struct IntrHandlerOptionParam {
size: i32, entry: u32, common: u32, gp: u32, intr_code: u16, sub_count: u16, intr_level: u16, enabled: u16, calls: u32, field_1c: u32, total_clock_lo: u32, total_clock_hi: u32, min_clock_lo: u32, min_clock_hi: u32, max_clock_lo: u32, max_clock_hi: u32, }
#[repr(u32)]
pub enum Interrupt {
Gpio = 4,
Ata = 5,
Umd = 6,
Mscm0 = 7,
Wlan = 8,
Audio = 10,
I2c = 12,
Sircs = 14,
Systimer0 = 15,
Systimer1 = 16,
Systimer2 = 17,
Systimer3 = 18,
Thread0 = 19,
Nand = 20,
Dmacplus = 21,
Dma0 = 22,
Dma1 = 23,
Memlmd = 24,
Ge = 25,
Vblank = 30,
Mecodec = 31,
Hpremote = 36,
Mscm1 = 60,
Mscm2 = 61,
Thread1 = 65,
Interrupt = 66,
}
#[cfg(not(feature = "stub-only"))]
impl fmt::Display for Interrupt {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
core::write!(
f,
"{}",
match self {
Self::Gpio => "GPIO",
Self::Ata => "ATA_ATAPI",
Self::Umd => "UmdMan",
Self::Mscm0 => "MScmNone",
Self::Wlan => "Wlan",
Self::Audio => "Audio",
Self::I2c => "I2C",
Self::Sircs => "SIRCS_IrDA",
Self::Systimer0 => "SystimerNone",
Self::Systimer1 => "Systimer1",
Self::Systimer2 => "Systimer2",
Self::Systimer3 => "Systimer3",
Self::Thread0 => "ThreadNone",
Self::Nand => "NAND",
Self::Dmacplus => "DMACPLUS",
Self::Dma0 => "DMANone",
Self::Dma1 => "DMA1",
Self::Memlmd => "Memlmd",
Self::Ge => "GE",
Self::Vblank => "Display",
Self::Mecodec => "MeCodec",
Self::Hpremote => "HP_Remote",
Self::Mscm1 => "MScm1",
Self::Mscm2 => "MScm2",
Self::Thread1 => "Thread1",
Self::Interrupt => "Interrupt",
}
)
}
}
#[repr(u32)]
pub enum SubInterrupt {
Gpio = Interrupt::Gpio as u32,
Ata = Interrupt::Ata as u32,
Umd = Interrupt::Umd as u32,
Dmacplus = Interrupt::Dmacplus as u32,
Ge = Interrupt::Ge as u32,
Display = Interrupt::Vblank as u32,
}
psp_extern! {
#![name = "InterruptManager"]
#![flags = 0x4000]
#![version = (0x00, 0x00)]
#[psp(0xCA04A2B9)]
pub fn sceKernelRegisterSubIntrHandler(
int_no: i32,
no: i32,
handler: *mut c_void,
arg: *mut c_void,
) -> i32;
#[psp(0xD61E6961)]
pub fn sceKernelReleaseSubIntrHandler(
int_no: i32,
no: i32,
) -> i32;
#[psp(0xFB8E22EC)]
pub fn sceKernelEnableSubIntr(
int_no: i32,
no: i32,
) -> i32;
#[psp(0x8A389411)]
pub fn sceKernelDisableSubIntr(
int_no: i32,
no: i32,
) -> i32;
#[psp(0xD2E8363F)]
pub fn QueryIntrHandlerInfo(
intr_code: SceUid,
sub_intr_code: SceUid,
data: *mut IntrHandlerOptionParam,
) -> i32;
}
psp_extern! {
#![name = "Kernel_Library"]
#![flags = 0x0001]
#![version = (0x00, 0x00)]
#[psp(0x092968F4)]
pub fn sceKernelCpuSuspendIntr() -> u32;
#[psp(0x5F10D406)]
pub fn sceKernelCpuResumeIntr(flags: u32);
#[psp(0x3B84732D)]
pub fn sceKernelCpuResumeIntrWithSync(flags: u32);
#[psp(0x47A0B729)]
pub fn sceKernelIsCpuIntrSuspended(flags: u32) -> i32;
#[psp(0xB55249D2)]
pub fn sceKernelIsCpuIntrEnable() -> i32;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SceKernelLMOption {
pub size: usize,
pub m_pid_text: SceUid,
pub m_pid_data: SceUid,
pub flags: u32,
pub position: u8,
pub access: u8,
pub c_reserved: [u8; 2usize],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SceKernelSMOption {
pub size: usize,
pub m_pid_stack: SceUid,
pub stack_size: usize,
pub priority: i32,
pub attribute: u32,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SceKernelModuleInfo {
pub size: usize,
pub n_segment: u8,
pub reserved: [u8; 3usize],
pub segment_addr: [i32; 4usize],
pub segment_size: [i32; 4usize],
pub entry_addr: u32,
pub gp_value: u32,
pub text_addr: u32,
pub text_size: u32,
pub data_size: u32,
pub bss_size: u32,
pub attribute: u16,
pub version: [u8; 2usize],
pub name: [u8; 28usize],
}
psp_extern! {
#![name = "ModuleMgrForUser"]
#![flags = 0x4001]
#![version = (0x00, 0x00)]
#[psp(0x977DE386)]
pub fn sceKernelLoadModule(
path: *const u8,
flags: i32,
option: *mut SceKernelLMOption,
) -> SceUid;
#[psp(0x710F61B5)]
pub fn sceKernelLoadModuleMs(
path: *const u8,
flags: i32,
option: *mut SceKernelLMOption,
) -> SceUid;
#[psp(0xB7F46618)]
pub fn sceKernelLoadModuleByID(
fid: SceUid,
flags: i32,
option: *mut SceKernelLMOption,
) -> SceUid;
#[psp(0xF9275D98)]
pub fn sceKernelLoadModuleBufferUsbWlan(
buf_size: usize,
buf: *mut c_void,
flags: i32,
option: *mut SceKernelLMOption,
) -> SceUid;
#[psp(0x50F0C1EC)]
pub fn sceKernelStartModule(
mod_id: SceUid,
arg_size: usize,
argp: *mut c_void,
status: *mut i32,
option: *mut SceKernelSMOption,
) -> i32;
#[psp(0xD1FF982A)]
pub fn sceKernelStopModule(
mod_id: SceUid,
arg_size: usize,
argp: *mut c_void,
status: *mut i32,
option: *mut SceKernelSMOption,
) -> i32;
#[psp(0x2E0911AA)]
pub fn sceKernelUnloadModule(mod_id: SceUid) -> i32;
#[psp(0xD675EBB8)]
pub fn sceKernelSelfStopUnloadModule(
unknown: i32,
arg_size: usize,
argp: *mut c_void,
) -> i32;
#[psp(0xCC1D3699)]
pub fn sceKernelStopUnloadSelfModule(
arg_size: usize,
argp: *mut c_void,
status: *mut i32,
option: *mut SceKernelSMOption,
) -> i32;
#[psp(0x748CBED9)]
pub fn sceKernelQueryModuleInfo(
mod_id: SceUid,
info: *mut SceKernelModuleInfo,
) -> i32;
#[psp(0x644395E2)]
pub fn sceKernelGetModuleIdList(
read_buf: *mut SceUid,
read_buf_size: i32,
id_count: *mut i32,
) -> i32;
}
psp_extern! {
#![name = "sceSuspendForUser"]
#![flags = 0x4000]
#![version = (0x00, 0x00)]
#[psp(0x3E0271D3)]
pub fn sceKernelVolatileMemLock(
unk: i32,
ptr: *mut *mut c_void,
size: *mut i32,
) -> i32;
#[psp(0xA14F40B2)]
pub fn sceKernelVolatileMemTryLock(
unk: i32,
ptr: *mut *mut c_void,
size: *mut i32,
) -> i32;
#[psp(0xA569E425)]
pub fn sceKernelVolatileMemUnlock(unk: i32) -> i32;
}
psp_extern! {
#![name = "StdioForUser"]
#![flags = 0x4001]
#![version = (0x00, 0x00)]
#[psp(0x172D316E)]
pub fn sceKernelStdin() -> SceUid;
#[psp(0xA6BAB2E9)]
pub fn sceKernelStdout() -> SceUid;
#[psp(0xF78BA90A)]
pub fn sceKernelStderr() -> SceUid;
}