Rust wrapper for libctru
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

481 lines
17 KiB

/* automatically generated by rust-bindgen */
#![allow(dead_code,
non_camel_case_types,
non_upper_case_globals,
non_snake_case)]
use ::{Handle, Result};
use ::ThreadFunc;
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum MemOp {
MEMOP_FREE = 1,
MEMOP_RESERVE = 2,
MEMOP_ALLOC = 3,
MEMOP_MAP = 4,
MEMOP_UNMAP = 5,
MEMOP_PROT = 6,
MEMOP_REGION_APP = 256,
MEMOP_REGION_SYSTEM = 512,
MEMOP_REGION_BASE = 768,
MEMOP_OP_MASK = 255,
MEMOP_REGION_MASK = 3840,
MEMOP_LINEAR_FLAG = 65536,
MEMOP_ALLOC_LINEAR = 65539,
}
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum MemState {
MEMSTATE_FREE = 0,
MEMSTATE_RESERVED = 1,
MEMSTATE_IO = 2,
MEMSTATE_STATIC = 3,
MEMSTATE_CODE = 4,
MEMSTATE_PRIVATE = 5,
MEMSTATE_SHARED = 6,
MEMSTATE_CONTINUOUS = 7,
MEMSTATE_ALIASED = 8,
MEMSTATE_ALIAS = 9,
MEMSTATE_ALIASCODE = 10,
MEMSTATE_LOCKED = 11,
}
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum MemPerm {
MEMPERM_READ = 1,
MEMPERM_WRITE = 2,
MEMPERM_EXECUTE = 4,
MEMPERM_DONTCARE = 268435456,
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct MemInfo {
pub base_addr: u32,
pub size: u32,
pub perm: u32,
pub state: u32,
}
impl ::core::default::Default for MemInfo {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct PageInfo {
pub flags: u32,
}
impl ::core::default::Default for PageInfo {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum ArbitrationType {
ARBITRATION_SIGNAL = 0,
ARBITRATION_WAIT_IF_LESS_THAN = 1,
ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN = 2,
ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT = 3,
ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN_TIMEOUT = 4,
}
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum ResetType { RESET_ONESHOT = 0, RESET_STICKY = 1, RESET_PULSE = 2, }
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum ThreadInfoType { THREADINFO_TYPE_UNKNOWN = 0, }
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum ProcessEventReason { REASON_CREATE = 1, REASON_ATTACH = 2, }
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct ProcessEvent {
pub program_id: u64,
pub process_name: [u8; 8usize],
pub process_id: u32,
pub reason: u32,
}
impl ::core::default::Default for ProcessEvent {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum ExitProcessEventReason {
EXITPROCESS_EVENT_NONE = 0,
EXITPROCESS_EVENT_TERMINATE = 1,
EXITPROCESS_EVENT_UNHANDLED_EXCEPTION = 2,
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct ExitProcessEvent {
pub reason: u32,
}
impl ::core::default::Default for ExitProcessEvent {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct CreateThreadEvent {
pub creator_thread_id: u32,
pub base_addr: u32,
pub entry_point: u32,
}
impl ::core::default::Default for CreateThreadEvent {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum ExitThreadEventReason {
EXITTHREAD_EVENT_NONE = 0,
EXITTHREAD_EVENT_TERMINATE = 1,
EXITTHREAD_EVENT_UNHANDLED_EXC = 2,
EXITTHREAD_EVENT_TERMINATE_PROCESS = 3,
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct ExitThreadEvent {
pub reason: u32,
}
impl ::core::default::Default for ExitThreadEvent {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum UserBreakType {
USERBREAK_PANIC = 0,
USERBREAK_ASSERT = 1,
USERBREAK_USER = 2,
}
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum ExceptionEventType {
EXC_EVENT_UNDEFINED_INSTRUCTION = 0,
EXC_EVENT_UNKNOWN1 = 1,
EXC_EVENT_UNKNOWN2 = 2,
EXC_EVENT_UNKNOWN3 = 3,
EXC_EVENT_ATTACH_BREAK = 4,
EXC_EVENT_BREAKPOINT = 5,
EXC_EVENT_USER_BREAK = 6,
EXC_EVENT_DEBUGGER_BREAK = 7,
EXC_EVENT_UNDEFINED_SYSCALL = 8,
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct ExceptionEvent {
pub type_: u32,
pub address: u32,
pub argument: u32,
}
impl ::core::default::Default for ExceptionEvent {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct SchedulerInOutEvent {
pub clock_tick: u64,
}
impl ::core::default::Default for SchedulerInOutEvent {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct SyscallInOutEvent {
pub clock_tick: u64,
pub syscall: u32,
_bindgen_padding_0_: [u8; 4usize],
}
impl ::core::default::Default for SyscallInOutEvent {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct OutputStringEvent {
pub string_addr: u32,
pub string_size: u32,
}
impl ::core::default::Default for OutputStringEvent {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct MapEvent {
pub mapped_addr: u32,
pub mapped_size: u32,
pub memperm: u32,
pub memstate: u32,
}
impl ::core::default::Default for MapEvent {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[derive(Copy, Clone)]
#[repr(u32)]
#[derive(Debug)]
pub enum DebugEventType {
DBG_EVENT_PROCESS = 0,
DBG_EVENT_CREATE_THREAD = 1,
DBG_EVENT_EXIT_THREAD = 2,
DBG_EVENT_EXIT_PROCESS = 3,
DBG_EVENT_EXCEPTION = 4,
DBG_EVENT_DLL_LOAD = 5,
DBG_EVENT_DLL_UNLOAD = 6,
DBG_EVENT_SCHEDULE_IN = 7,
DBG_EVENT_SCHEDULE_OUT = 8,
DBG_EVENT_SYSCALL_IN = 9,
DBG_EVENT_SYSCALL_OUT = 10,
DBG_EVENT_OUTPUT_STRING = 11,
DBG_EVENT_MAP = 12,
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct DebugEventInfo {
pub type_: u32,
pub thread_id: u32,
pub unknown: [u32; 2usize],
pub _bindgen_data_1_: [u64; 3usize],
}
impl DebugEventInfo {
pub unsafe fn process(&mut self) -> *mut ProcessEvent {
let raw: *mut u8 = ::core::mem::transmute(&self._bindgen_data_1_);
::core::mem::transmute(raw.offset(0))
}
pub unsafe fn create_thread(&mut self) -> *mut CreateThreadEvent {
let raw: *mut u8 = ::core::mem::transmute(&self._bindgen_data_1_);
::core::mem::transmute(raw.offset(0))
}
pub unsafe fn exit_thread(&mut self) -> *mut ExitThreadEvent {
let raw: *mut u8 = ::core::mem::transmute(&self._bindgen_data_1_);
::core::mem::transmute(raw.offset(0))
}
pub unsafe fn exit_process(&mut self) -> *mut ExitProcessEvent {
let raw: *mut u8 = ::core::mem::transmute(&self._bindgen_data_1_);
::core::mem::transmute(raw.offset(0))
}
pub unsafe fn exception(&mut self) -> *mut ExceptionEvent {
let raw: *mut u8 = ::core::mem::transmute(&self._bindgen_data_1_);
::core::mem::transmute(raw.offset(0))
}
pub unsafe fn scheduler(&mut self) -> *mut SchedulerInOutEvent {
let raw: *mut u8 = ::core::mem::transmute(&self._bindgen_data_1_);
::core::mem::transmute(raw.offset(0))
}
pub unsafe fn syscall(&mut self) -> *mut SyscallInOutEvent {
let raw: *mut u8 = ::core::mem::transmute(&self._bindgen_data_1_);
::core::mem::transmute(raw.offset(0))
}
pub unsafe fn output_string(&mut self) -> *mut OutputStringEvent {
let raw: *mut u8 = ::core::mem::transmute(&self._bindgen_data_1_);
::core::mem::transmute(raw.offset(0))
}
pub unsafe fn map(&mut self) -> *mut MapEvent {
let raw: *mut u8 = ::core::mem::transmute(&self._bindgen_data_1_);
::core::mem::transmute(raw.offset(0))
}
}
impl ::core::default::Default for DebugEventInfo {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct CodeSetInfo {
pub name: [u8; 8usize],
pub unk1: u16,
pub unk2: u16,
pub unk3: u32,
pub text_addr: u32,
pub text_size: u32,
pub ro_addr: u32,
pub ro_size: u32,
pub rw_addr: u32,
pub rw_size: u32,
pub text_size_total: u32,
pub ro_size_total: u32,
pub rw_size_total: u32,
pub unk4: u32,
pub program_id: u64,
}
impl ::core::default::Default for CodeSetInfo {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug)]
pub struct StartupInfo {
pub priority: ::libc::c_int,
pub stack_size: u32,
pub argc: ::libc::c_int,
pub argv: *mut u16,
pub envp: *mut u16,
}
impl ::core::default::Default for StartupInfo {
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
extern "C" {
pub fn svcControlMemory(addr_out: *mut u32, addr0: u32, addr1: u32,
size: u32, op: MemOp, perm: MemPerm) -> Result;
pub fn svcControlProcessMemory(process: Handle, addr0: u32, addr1: u32,
size: u32, type_: u32, perm: u32)
-> Result;
pub fn svcCreateMemoryBlock(memblock: *mut Handle, addr: u32, size: u32,
my_perm: MemPerm, other_perm: MemPerm)
-> Result;
pub fn svcMapMemoryBlock(memblock: Handle, addr: u32, my_perm: MemPerm,
other_perm: MemPerm) -> Result;
pub fn svcMapProcessMemory(process: Handle, startAddr: u32,
endAddr: u32) -> Result;
pub fn svcUnmapProcessMemory(process: Handle, startAddr: u32,
endAddr: u32) -> Result;
pub fn svcUnmapMemoryBlock(memblock: Handle, addr: u32) -> Result;
pub fn svcStartInterProcessDma(dma: *mut Handle, dstProcess: Handle,
dst: *mut ::libc::c_void,
srcProcess: Handle,
src: *const ::libc::c_void, size: u32,
dmaConfig: *mut ::libc::c_void) -> Result;
pub fn svcStopDma(dma: Handle) -> Result;
pub fn svcGetDmaState(dmaState: *mut ::libc::c_void, dma: Handle)
-> Result;
pub fn svcQueryMemory(info: *mut MemInfo, out: *mut PageInfo, addr: u32)
-> Result;
pub fn svcQueryProcessMemory(info: *mut MemInfo, out: *mut PageInfo,
process: Handle, addr: u32) -> Result;
pub fn svcInvalidateProcessDataCache(process: Handle,
addr: *mut ::libc::c_void,
size: u32) -> Result;
pub fn svcFlushProcessDataCache(process: Handle,
addr: *const ::libc::c_void, size: u32)
-> Result;
pub fn svcReadProcessMemory(buffer: *mut ::libc::c_void, debug: Handle,
addr: u32, size: u32) -> Result;
pub fn svcWriteProcessMemory(debug: Handle, buffer: *const ::libc::c_void,
addr: u32, size: u32) -> Result;
pub fn svcOpenProcess(process: *mut Handle, processId: u32) -> Result;
pub fn svcExitProcess();
pub fn svcTerminateProcess(process: Handle) -> Result;
pub fn svcGetProcessInfo(out: *mut i64, process: Handle, type_: u32)
-> Result;
pub fn svcGetProcessId(out: *mut u32, handle: Handle) -> Result;
pub fn svcGetProcessList(processCount: *mut i32, processIds: *mut u32,
processIdMaxCount: i32) -> Result;
pub fn svcCreatePort(portServer: *mut Handle, portClient: *mut Handle,
name: *const ::libc::c_char, maxSessions: i32)
-> Result;
pub fn svcConnectToPort(out: *mut Handle, portName: *const ::libc::c_char)
-> Result;
pub fn svcCreateCodeSet(out: *mut Handle, info: *const CodeSetInfo,
code_ptr: *mut ::libc::c_void,
ro_ptr: *mut ::libc::c_void,
data_ptr: *mut ::libc::c_void) -> Result;
pub fn svcCreateProcess(out: *mut Handle, codeset: Handle,
arm11kernelcaps: *const u32,
arm11kernelcaps_num: u32) -> Result;
pub fn svcSetProcessAffinityMask(process: Handle,
affinitymask: *const u8,
processorcount: i32) -> Result;
pub fn svcSetProcessIdealProcessor(process: Handle, processorid: i32)
-> Result;
pub fn svcRun(process: Handle, info: *const StartupInfo) -> Result;
pub fn svcCreateThread(thread: *mut Handle, entrypoint: ThreadFunc,
arg: u32, stack_top: *mut u32,
thread_priority: i32, processor_id: i32) -> Result;
pub fn svcOpenThread(thread: *mut Handle, process: Handle, threadId: u32)
-> Result;
pub fn svcExitThread();
pub fn svcSleepThread(ns: i64);
pub fn svcGetThreadPriority(out: *mut i32, handle: Handle) -> Result;
pub fn svcSetThreadPriority(thread: Handle, prio: i32) -> Result;
pub fn svcGetThreadAffinityMask(affinitymask: *mut u8, thread: Handle,
processorcount: i32) -> Result;
pub fn svcSetThreadAffinityMask(thread: Handle, affinitymask: *const u8,
processorcount: i32) -> Result;
pub fn svcGetThreadIdealProcessor(processorid: *mut i32, thread: Handle)
-> Result;
pub fn svcSetThreadIdealProcessor(thread: Handle, processorid: i32)
-> Result;
pub fn svcGetProcessorID() -> i32;
pub fn svcGetThreadId(out: *mut u32, handle: Handle) -> Result;
pub fn svcGetResourceLimit(resourceLimit: *mut Handle, process: Handle)
-> Result;
pub fn svcGetResourceLimitLimitValues(values: *mut i64,
resourceLimit: Handle,
names: *mut u32, nameCount: i32)
-> Result;
pub fn svcGetResourceLimitCurrentValues(values: *mut i64,
resourceLimit: Handle,
names: *mut u32, nameCount: i32)
-> Result;
pub fn svcGetProcessIdOfThread(out: *mut u32, handle: Handle) -> Result;
pub fn svcGetThreadInfo(out: *mut i64, thread: Handle,
type_: ThreadInfoType) -> Result;
pub fn svcCreateMutex(mutex: *mut Handle, initially_locked: u8) -> Result;
pub fn svcReleaseMutex(handle: Handle) -> Result;
pub fn svcCreateSemaphore(semaphore: *mut Handle, initial_count: i32,
max_count: i32) -> Result;
pub fn svcReleaseSemaphore(count: *mut i32, semaphore: Handle,
release_count: i32) -> Result;
pub fn svcCreateEvent(event: *mut Handle, reset_type: ResetType)
-> Result;
pub fn svcSignalEvent(handle: Handle) -> Result;
pub fn svcClearEvent(handle: Handle) -> Result;
pub fn svcWaitSynchronization(handle: Handle, nanoseconds: i64) -> Result;
pub fn svcWaitSynchronizationN(out: *mut i32, handles: *mut Handle,
handles_num: i32, wait_all: u8,
nanoseconds: i64) -> Result;
pub fn svcCreateAddressArbiter(arbiter: *mut Handle) -> Result;
pub fn svcArbitrateAddress(arbiter: Handle, addr: u32,
type_: ArbitrationType, value: i32,
nanoseconds: i64) -> Result;
pub fn svcSendSyncRequest(session: Handle) -> Result;
pub fn svcAcceptSession(session: *mut Handle, port: Handle) -> Result;
pub fn svcReplyAndReceive(index: *mut i32, handles: *mut Handle,
handleCount: i32, replyTarget: Handle)
-> Result;
pub fn svcBindInterrupt(interruptId: u32, event: Handle, priority: i32,
isManualClear: u8) -> Result;
pub fn svcUnbindInterrupt(interruptId: u32, event: Handle) -> Result;
pub fn svcCreateTimer(timer: *mut Handle, reset_type: ResetType)
-> Result;
pub fn svcSetTimer(timer: Handle, initial: i64, interval: i64) -> Result;
pub fn svcCancelTimer(timer: Handle) -> Result;
pub fn svcClearTimer(timer: Handle) -> Result;
pub fn svcGetSystemTick() -> u64;
pub fn svcCloseHandle(handle: Handle) -> Result;
pub fn svcDuplicateHandle(out: *mut Handle, original: Handle) -> Result;
pub fn svcGetSystemInfo(out: *mut i64, type_: u32, param: i32) -> Result;
pub fn svcKernelSetState(type_: u32, param0: u32, param1: u32,
param2: u32) -> Result;
pub fn svcBreak(breakReason: UserBreakType);
pub fn svcOutputDebugString(str: *const ::libc::c_char,
length: ::libc::c_int) -> Result;
pub fn svcDebugActiveProcess(debug: *mut Handle, processId: u32)
-> Result;
pub fn svcBreakDebugProcess(debug: Handle) -> Result;
pub fn svcTerminateDebugProcess(debug: Handle) -> Result;
pub fn svcGetProcessDebugEvent(info: *mut DebugEventInfo, debug: Handle)
-> Result;
pub fn svcContinueDebugEvent(debug: Handle, flags: u32) -> Result;
pub fn svcBackdoor(callback:
::core::option::Option<extern "C" fn() -> i32>)
-> Result;
}