aboutsummaryrefslogtreecommitdiff
path: root/ctru-sys
diff options
context:
space:
mode:
authorFenrir <[email protected]>2016-05-02 21:10:45 -0700
committerFenrir <[email protected]>2016-05-02 22:03:42 -0700
commitc314c0098ec01aa5f806ce4fd31410e74ad686d9 (patch)
tree24773c04a6444792e7244f7b3c3c6a27f3093bff /ctru-sys
parentDeleted old files (diff)
downloadctru-rs-c314c0098ec01aa5f806ce4fd31410e74ad686d9.tar.xz
ctru-rs-c314c0098ec01aa5f806ce4fd31410e74ad686d9.zip
Added new bindings
Diffstat (limited to 'ctru-sys')
-rw-r--r--ctru-sys/Cargo.toml4
-rw-r--r--ctru-sys/src/env.rs14
-rw-r--r--ctru-sys/src/gfx.rs41
-rw-r--r--ctru-sys/src/gpu/gpu.rs308
-rw-r--r--ctru-sys/src/gpu/gx.rs55
-rw-r--r--ctru-sys/src/gpu/mod.rs8
-rw-r--r--ctru-sys/src/gpu/registers.rs19
-rw-r--r--ctru-sys/src/gpu/shaderProgram.rs89
-rw-r--r--ctru-sys/src/gpu/shader_program.rs42
-rw-r--r--ctru-sys/src/gpu/shbin.rs193
-rw-r--r--ctru-sys/src/ipc.rs10
-rw-r--r--ctru-sys/src/lib.rs14
-rw-r--r--ctru-sys/src/linear.rs10
-rw-r--r--ctru-sys/src/lock.rs33
-rw-r--r--ctru-sys/src/os.rs49
-rw-r--r--ctru-sys/src/services/ac.rs9
-rw-r--r--ctru-sys/src/services/am.rs49
-rw-r--r--ctru-sys/src/services/apt.rs242
-rw-r--r--ctru-sys/src/services/cam.rs410
-rw-r--r--ctru-sys/src/services/cfgnor.rs12
-rw-r--r--ctru-sys/src/services/cfgu.rs39
-rw-r--r--ctru-sys/src/services/dsp.rs48
-rw-r--r--ctru-sys/src/services/fs.rs536
-rw-r--r--ctru-sys/src/services/gsp.rs83
-rw-r--r--ctru-sys/src/services/gspgpu.rs120
-rw-r--r--ctru-sys/src/services/gsplcd.rs17
-rw-r--r--ctru-sys/src/services/hb.rs6
-rw-r--r--ctru-sys/src/services/hid.rs101
-rw-r--r--ctru-sys/src/services/httpc.rs79
-rw-r--r--ctru-sys/src/services/ir.rs17
-rw-r--r--ctru-sys/src/services/irrst.rs16
-rw-r--r--ctru-sys/src/services/mic.rs53
-rw-r--r--ctru-sys/src/services/mod.rs16
-rw-r--r--ctru-sys/src/services/mvd.rs67
-rw-r--r--ctru-sys/src/services/news.rs11
-rw-r--r--ctru-sys/src/services/ns.rs4
-rw-r--r--ctru-sys/src/services/pm.rs24
-rw-r--r--ctru-sys/src/services/ps.rs46
-rw-r--r--ctru-sys/src/services/ptm.rs12
-rw-r--r--ctru-sys/src/services/ptmsysm.rs7
-rw-r--r--ctru-sys/src/services/ptmu.rs11
-rw-r--r--ctru-sys/src/services/qtm.rs44
-rw-r--r--ctru-sys/src/services/soc.rs6
-rw-r--r--ctru-sys/src/services/srvpm.rs12
-rw-r--r--ctru-sys/src/services/y2r.rs185
-rw-r--r--ctru-sys/src/svc.rs570
-rw-r--r--ctru-sys/src/synchronization.rs19
-rw-r--r--ctru-sys/src/thread.rs19
48 files changed, 2778 insertions, 1001 deletions
diff --git a/ctru-sys/Cargo.toml b/ctru-sys/Cargo.toml
index 5597f9b..578ee82 100644
--- a/ctru-sys/Cargo.toml
+++ b/ctru-sys/Cargo.toml
@@ -1,5 +1,5 @@
[package]
name = "ctru-sys"
-version = "0.1.0"
-authors = ["Ronald Kinard <[email protected]>", "FenrirWolf <[email protected]>"]
+version = "0.2.0"
+authors = ["Ronald Kinard <[email protected]>"]
license = "https://en.wikipedia.org/wiki/Zlib_License"
diff --git a/ctru-sys/src/env.rs b/ctru-sys/src/env.rs
new file mode 100644
index 0000000..2de21e4
--- /dev/null
+++ b/ctru-sys/src/env.rs
@@ -0,0 +1,14 @@
+//TODO: There are a bunch of static inline functions that bindgen didn't pick up and idk how they work
+
+use ::Handle;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed1 {
+ RUNFLAG_APTWORKAROUND = 1,
+ RUNFLAG_APTREINIT = 2,
+}
+
+extern "C" {
+ pub fn envGetHandle(name: *const u8) -> Handle;
+}
diff --git a/ctru-sys/src/gfx.rs b/ctru-sys/src/gfx.rs
index ed40baf..1af87ee 100644
--- a/ctru-sys/src/gfx.rs
+++ b/ctru-sys/src/gfx.rs
@@ -1,13 +1,13 @@
-use services::gsp::*;
+use services::gspgpu::*;
#[inline]
-pub fn RGB565(r: u32, g: u32, b: u32) {
- (((b)&0x1f)|(((g)&0x3f)<<5)|(((r)&0x1f)<<11));
+pub fn RGB565(r: u32, g: u32, b: u32) -> u32 {
+ (((b)&0x1f)|(((g)&0x3f)<<5)|(((r)&0x1f)<<11))
}
#[inline]
-pub fn RGB8_to_565(r: u32, g: u32, b: u32) {
- (((b)>>3)&0x1f)|((((g)>>2)&0x3f)<<5)|((((r)>>3)&0x1f)<<11);
+pub fn RGB8_to_565(r: u32, g: u32, b: u32) -> u32 {
+ (((b)>>3)&0x1f)|((((g)>>2)&0x3f)<<5)|((((r)>>3)&0x1f)<<11)
}
#[repr(C)]
@@ -22,22 +22,27 @@ pub enum gfx3dSide_t {
GFX_RIGHT = 1
}
-
extern "C" {
pub static mut gfxTopLeftFramebuffers: [*mut u8; 2usize];
pub static mut gfxTopRightFramebuffers: [*mut u8; 2usize];
pub static mut gfxBottomFramebuffers: [*mut u8; 2usize];
- pub static mut gxCmdBuf: *mut u32;
- pub fn gfxInitDefault() -> ();
- pub fn gfxInit(topFormat: GSP_FramebufferFormats, bottomFormat: GSP_FramebufferFormats, vrambuffers: u8) -> ();
- pub fn gfxExit() -> ();
- pub fn gfxSet3D(enable: u8) -> ();
- pub fn gfxSetScreenFormat(screen: gfxScreen_t, format: GSP_FramebufferFormats) -> ();
- pub fn gfxGetScreenFormat(screen: gfxScreen_t) -> GSP_FramebufferFormats;
- pub fn gfxSetDoubleBuffering(screen: gfxScreen_t, doubleBuffering: u8) -> ();
- pub fn gfxFlushBuffers() -> ();
- pub fn gfxSwapBuffers() -> ();
- pub fn gfxSwapBuffersGpu() -> ();
- pub fn gfxGetFramebuffer(screen: gfxScreen_t, side: gfx3dSide_t, width: *mut u16, height: *mut u16) -> *mut u8;
+ pub fn gfxInitDefault();
+ pub fn gfxInit(topFormat: GSPGPU_FramebufferFormats,
+ bottomFormat: GSPGPU_FramebufferFormats, vrambuffers: u8);
+ pub fn gfxExit();
+ pub fn gfxSet3D(enable: u8);
+ pub fn gfxIs3D() -> u8;
+ pub fn gfxSetScreenFormat(screen: gfxScreen_t,
+ format: GSPGPU_FramebufferFormats);
+ pub fn gfxGetScreenFormat(screen: gfxScreen_t)
+ -> GSPGPU_FramebufferFormats;
+ pub fn gfxSetDoubleBuffering(screen: gfxScreen_t, doubleBuffering: u8);
+ pub fn gfxFlushBuffers();
+ pub fn gfxConfigScreen(scr: gfxScreen_t, immediate: u8);
+ pub fn gfxSwapBuffers();
+ pub fn gfxSwapBuffersGpu();
+ pub fn gfxGetFramebuffer(screen: gfxScreen_t, side: gfx3dSide_t,
+ width: *mut u16, height: *mut u16) -> *mut u8;
+
}
diff --git a/ctru-sys/src/gpu/gpu.rs b/ctru-sys/src/gpu/gpu.rs
index 24f2f90..30e7a03 100644
--- a/ctru-sys/src/gpu/gpu.rs
+++ b/ctru-sys/src/gpu/gpu.rs
@@ -1,294 +1,26 @@
-use ctru::Handle;
+/* automatically generated by rust-bindgen */
#[inline]
-pub fn GPUCMD_HEADER(incremental: i32, mask: i32, reg: i32) {
- (((incremental)<<31)|(((mask)&0xF)<<16)|((reg)&0x3FF));
+pub fn GPUCMD_HEADER(incremental: u32, mask: u32, reg: u32) -> u32{
+ (((incremental)<<31)|(((mask)&0xF)<<16)|((reg)&0x3FF))
}
-#[inline]
-pub fn GPU_TEXTURE_MAG_FILTER(v: i32) {
- (((v)&0x1)<<1); //takes a GPU_TEXTURE_FILTER_PARAM
-}
-
-#[inline]
-pub fn GPU_TEXTURE_MIN_FILTER(v: i32) {
- (((v)&0x1)<<2); //takes a GPU_TEXTURE_FILTER_PARAM
-}
-
-#[inline]
-pub fn GPU_TEXTURE_WRAP_S(v: i32) {
- (((v)&0x3)<<8); //takes a GPU_TEXTURE_WRAP_PARAM
-}
-
-#[inline]
-pub fn GPU_TEXTURE_WRAP_T(v: i32) {
- (((v)&0x3)<<12); //takes a GPU_TEXTURE_WRAP_PARAM
-}
-
-#[repr(C)]
-pub enum GPU_TEXTURE_FILTER_PARAM {
- GPU_NEAREST = 0x0,
- GPU_LINEAR = 0x1
-}
-
-#[repr(C)]
-pub enum GPU_TEXTURE_WRAP_PARAM {
- GPU_CLAMP_TO_EDGE = 0x0,
- GPU_REPEAT = 0x1
-}
-
-#[repr(C)]
-pub enum GPU_TEXUNIT {
- GPU_TEXUNIT0 = 0x1,
- GPU_TEXUNIT1 = 0x2,
- GPU_TEXUNIT2 = 0x4
-}
-
-#[repr(C)]
-pub enum GPU_TEXCOLOR {
- GPU_RGBA8=0x0,
- GPU_RGB8=0x1,
- GPU_RGBA5551=0x2,
- GPU_RGB565=0x3,
- GPU_RGBA4=0x4,
- GPU_LA8=0x5,
- GPU_HILO8=0x6,
- GPU_L8=0x7,
- GPU_A8=0x8,
- GPU_LA4=0x9,
- GPU_L4=0xA,
- GPU_ETC1=0xB,
- GPU_ETC1A4=0xC
-}
-
-#[repr(C)]
-pub enum GPU_TESTFUNC {
- GPU_NEVER = 0,
- GPU_ALWAYS = 1,
- GPU_EQUAL = 2,
- GPU_NOTEQUAL = 3,
- GPU_LESS = 4,
- GPU_LEQUAL = 5,
- GPU_GREATER = 6,
- GPU_GEQUAL = 7
-}
-
-#[repr(C)]
-pub enum GPU_SCISSORMODE {
- GPU_SCISSOR_DISABLE = 0, // disable scissor test
- GPU_SCISSOR_INVERT = 1, // exclude pixels inside the scissor box
- // 2 is the same as 0
- GPU_SCISSOR_NORMAL = 3, // exclude pixels outside of the scissor box
-}
-
-#[repr(C)]
-pub enum GPU_STENCILOP {
- GPU_KEEP = 0, // keep destination value
- GPU_AND_NOT = 1, // destination & ~source
- GPU_XOR = 5, // destination ^ source
- // 2 is the same as 1. Other values are too weird to even be usable.
-}
-
-#[repr(C)]
-pub enum GPU_WRITEMASK {
- GPU_WRITE_RED = 0x01,
- GPU_WRITE_GREEN = 0x02,
- GPU_WRITE_BLUE = 0x04,
- GPU_WRITE_ALPHA = 0x08,
- GPU_WRITE_DEPTH = 0x10,
-
- GPU_WRITE_COLOR = 0x0F,
- GPU_WRITE_ALL = 0x1F
-}
-
-#[repr(C)]
-pub enum GPU_BLENDEQUATION {
- GPU_BLEND_ADD = 0,
- GPU_BLEND_SUBTRACT = 1,
- GPU_BLEND_REVERSE_SUBTRACT = 2,
- GPU_BLEND_MIN = 3,
- GPU_BLEND_MAX = 4
-}
-
-#[repr(C)]
-pub enum GPU_BLENDFACTOR {
- GPU_ZERO = 0,
- GPU_ONE = 1,
- GPU_SRC_COLOR = 2,
- GPU_ONE_MINUS_SRC_COLOR = 3,
- GPU_DST_COLOR = 4,
- GPU_ONE_MINUS_DST_COLOR = 5,
- GPU_SRC_ALPHA = 6,
- GPU_ONE_MINUS_SRC_ALPHA = 7,
- GPU_DST_ALPHA = 8,
- GPU_ONE_MINUS_DST_ALPHA = 9,
- GPU_CONSTANT_COLOR = 10,
- GPU_ONE_MINUS_CONSTANT_COLOR = 11,
- GPU_CONSTANT_ALPHA = 12,
- GPU_ONE_MINUS_CONSTANT_ALPHA = 13,
- GPU_SRC_ALPHA_SATURATE = 14
-}
-
-#[repr(C)]
-pub enum GPU_LOGICOP {
- GPU_LOGICOP_CLEAR = 0,
- GPU_LOGICOP_AND = 1,
- GPU_LOGICOP_AND_REVERSE = 2,
- GPU_LOGICOP_COPY = 3,
- GPU_LOGICOP_SET = 4,
- GPU_LOGICOP_COPY_INVERTED = 5,
- GPU_LOGICOP_NOOP = 6,
- GPU_LOGICOP_INVERT = 7,
- GPU_LOGICOP_NAND = 8,
- GPU_LOGICOP_OR = 9,
- GPU_LOGICOP_NOR = 10,
- GPU_LOGICOP_XOR = 11,
- GPU_LOGICOP_EQUIV = 12,
- GPU_LOGICOP_AND_INVERTED = 13,
- GPU_LOGICOP_OR_REVERSE = 14,
- GPU_LOGICOP_OR_INVERTED = 15
-}
-
-#[repr(C)]
-pub enum GPU_FORMATS {
- GPU_BYTE = 0,
- GPU_UNSIGNED_BYTE = 1,
- GPU_SHORT = 2,
- GPU_FLOAT = 3
-}
-
-//defines for CW ?
-#[repr(C)]
-pub enum GPU_CULLMODE {
- GPU_CULL_NONE = 0,
- GPU_CULL_FRONT_CCW = 1,
- GPU_CULL_BACK_CCW = 2
-}
-
-#[inline]
-pub fn GU_ATTRIBFMT(i: i32, n: i32, f: i32) {
- (((((n)-1)<<2)|((f)&3))<<((i)*4));
-}
-
-/**
-* Texture combiners sources
-*/
-#[repr(C)]
-pub enum GPU_TEVSRC{
- GPU_PRIMARY_COLOR = 0x00,
- GPU_TEXTURE0 = 0x03,
- GPU_TEXTURE1 = 0x04,
- GPU_TEXTURE2 = 0x05,
- GPU_TEXTURE3 = 0x06,
- GPU_CONSTANT = 0x0E,
- GPU_PREVIOUS = 0x0F,
-}
-
-/**
-* Texture RGB combiners operands
-*/
-#[repr(C)]
-pub enum GPU_TEVOP_RGB{
- GPU_TEVOP_RGB_SRC_COLOR = 0x00,
- GPU_TEVOP_RGB_ONE_MINUS_SRC_COLOR = 0x01,
- GPU_TEVOP_RGB_SRC_ALPHA = 0x02,
- GPU_TEVOP_RGB_ONE_MINUS_SRC_ALPHA = 0x03,
- GPU_TEVOP_RGB_SRC0_RGB = 0x04,
- GPU_TEVOP_RGB_0x05 = 0x05,
- GPU_TEVOP_RGB_0x06 = 0x06,
- GPU_TEVOP_RGB_0x07 = 0x07,
- GPU_TEVOP_RGB_SRC1_RGB = 0x08,
- GPU_TEVOP_RGB_0x09 = 0x09,
- GPU_TEVOP_RGB_0x0A = 0x0A,
- GPU_TEVOP_RGB_0x0B = 0x0B,
- GPU_TEVOP_RGB_SRC2_RGB = 0x0C,
- GPU_TEVOP_RGB_0x0D = 0x0D,
- GPU_TEVOP_RGB_0x0E = 0x0E,
- GPU_TEVOP_RGB_0x0F = 0x0F,
-};
-
-/**
-* Texture ALPHA combiners operands
-*/
-#[repr(C)]
-pub enum GPU_TEVOP_A {
- GPU_TEVOP_A_SRC_ALPHA = 0x00,
- GPU_TEVOP_A_ONE_MINUS_SRC_ALPHA = 0x01,
- GPU_TEVOP_A_SRC0_RGB = 0x02,
- GPU_TEVOP_A_SRC1_RGB = 0x04,
- GPU_TEVOP_A_SRC2_RGB = 0x06,
-}
-
-/**
-* Texture combiner functions
-*/
-pub enum GPU_COMBINEFUNC {
- GPU_REPLACE = 0x00,
- GPU_MODULATE = 0x01,
- GPU_ADD = 0x02,
- GPU_ADD_SIGNED = 0x03,
- GPU_INTERPOLATE = 0x04,
- GPU_SUBTRACT = 0x05,
- GPU_DOT3_RGB = 0x06 //RGB only
-}
-
-#[inline]
-pub fn GPU_TEVSOURCES(a, b, c) {
- (((a))|((b)<<4)|((c)<<8));
-}
-
-#[inline]
-pub fn GPU_TEVOPERANDS(a, b, c) {
- (((a))|((b)<<4)|((c)<<8));
-}
-
-#[repr(C)]
-pub enum GPU_Primitive_t {
- GPU_TRIANGLES = 0x0000,
- GPU_TRIANGLE_STRIP = 0x0100,
- GPU_TRIANGLE_FAN = 0x0200,
- GPU_UNKPRIM = 0x0300 // ?
-}
-
-#[repr(C)]
-pub enum GPU_SHADER_TYPE {
- GPU_VERTEX_SHADER=0x0,
- GPU_GEOMETRY_SHADER=0x1
-}
-
-
extern "C" {
- pub fn GPU_Init(gsphandle: *mut Handle) -> ();
- pub fn GPU_Reset(gxbuf: *mut u32, gpuBuf: *mut u32, gpuBufSize: u32) -> ();
-
- pub fn GPUCMD_SetBuffer(adr: *mut u32, size: u32, offset: u32) -> ();
- pub fn GPUCMD_SetBufferOffset(offset: u32) -> ();
- pub fn GPUCMD_GetBuffer(adr: *mut *mut u32, size: *mut u32, offset: *mut u32) -> ();
- pub fn GPUCMD_AddRawCommands(cmd: *mut u32, size: u32) -> ();
- pub fn GPUCMD_Run(gxbuf: *mut u32) -> ();
- pub fn GPUCMD_FlushAndRun(gxbuf: *mut u32) -> ();
- pub fn GPUCMD_Add(header: u32, param: *mut u32, paramlength: u32) -> ();
- pub fn GPUCMD_Finalize() -> ();
- pub fn GPU_SetFloatUniform(_type: GPU_SHADER_TYPE, startreg: u32, data: *mut u32, numreg: u32) -> ();
- pub fn GPU_SetViewport(depthBuffer: *mut u32, colorBuffer: *mut u32, x: u32, y: u32, w: u32, h: u32) -> ();
- pub fn GPU_SetScissorTest(mode: GPU_SCISSORMODE, x: u32, y: u32, w: u32, h: u32) -> ();
- pub fn GPU_DepthMap(zScale: f32, zOffset: f32) -> ();
- pub fn GPU_SetAlphaTest(enable: u8, function: GPU_TESTFUNC, _ref: u8) -> ();
- pub fn GPU_SetDepthTestAndWriteMask(enable: u8, function: GPU_TESTFUNC, writemask: GPU_WRITEMASK) -> ();
- pub fn GPU_SetStencilTest(enable: u8, function: GPU_TESTFUNC, _ref: _u8, mask: _u8, replace: _u8) -> ();
- pub fn GPU_SetStencilOp(sfail: GPU_STENCILOP, dfail: GPU_STENCILOP, pass: GPU_STENCILOP) -> ();
- pub fn GPU_SetFaceCulling(mode: GPU_CULLMODE) -> ();
- pub fn GPU_SetAlphaBlending(colorEquation: GPU_BLENDEQUATION, alphaEquation: GPU_BLENDEQUATION, colorSrc: GPU_BLENDFACTOR, colorDst: GPU_BLENDFACTOR, alphaSrc: GPU_BLENDFACTOR, alphaDst: GPU_BLENDFACTOR) -> ();
- pub fn GPU_SetColorLogicOp(op: GPU_LOGICOP) -> ();
- pub fn GPU_SetBlendingColor(r: u8, g: u8, b: u8, a: u8) -> ();
- pub fn GPU_SetAttributeBuffers(totalAttributes: u8, baseAddress: *mut u32, attributeFormats: u64, attributeMask: u16, attributePermutation: u64, numBuffers: u8, bufferOffsets: *mut u32, bufferPermutations: *mut u64, bufferNumAttributes: *mut u8) -> ();
- pub fn GPU_SetTextureEnable(units: GPU_TEXUNIT) -> ();
- pub fn GPU_SetTexture(unit: GPU_TEXUNIT, data: *mut u32, width: u16, height: u16, param: u32, colorType: GPU_TEXCOLOR) -> ();
- pub fn GPU_SetTexEnv(id: u8, rgbSources: u16, alphaSources: u16, rgbOperands: u16, alphaOperands: u16, rgbCombine: GPU_COMBINEFUNC, alphaCombine: GPU_COMBINEFUNC, constantColor: u32) -> ();
- pub fn GPU_DrawArray(primitive: GPU_Primitive_t, n: u32) -> ();
- pub fn GPU_DrawElements(primitive: GPU_Primitive_t, indexArray: *mut u32, n: u32) -> ();
- pub fn GPU_FinishDrawing() -> ();
- pub fn GPU_SetShaderOutmap(outmapData: *mut u32) -> ();
- pub fn GPU_SendShaderCode(_type: GPU_SHADER_TYPE, data: *mut u32, offset: u16, length: u16) -> ();
- pub fn GPU_SendOperandDescriptors(_type: GPU_SHADER_TYPE, data: *mut u32, offset: u16, length: u16) -> ();
+ pub static mut gpuCmdBuf: *mut u32;
+ pub static mut gpuCmdBufSize: u32;
+ pub static mut gpuCmdBufOffset: u32;
+
+ pub fn GPUCMD_SetBuffer(adr: *mut u32, size: u32, offset: u32);
+ pub fn GPUCMD_SetBufferOffset(offset: u32);
+ pub fn GPUCMD_GetBuffer(adr: *mut *mut u32, size: *mut u32,
+ offset: *mut u32);
+ pub fn GPUCMD_AddRawCommands(cmd: *mut u32, size: u32);
+ pub fn GPUCMD_Run();
+ pub fn GPUCMD_FlushAndRun();
+ pub fn GPUCMD_Add(header: u32, param: *mut u32, paramlength: u32);
+ pub fn GPUCMD_Finalize();
+ pub fn f32tof16(f: f32) -> u32;
+ pub fn f32tof20(f: f32) -> u32;
+ pub fn f32tof24(f: f32) -> u32;
+ pub fn f32tof31(f: f32) -> u32;
}
diff --git a/ctru-sys/src/gpu/gx.rs b/ctru-sys/src/gpu/gx.rs
index d26c9ab..69eeddf 100644
--- a/ctru-sys/src/gpu/gx.rs
+++ b/ctru-sys/src/gpu/gx.rs
@@ -1,3 +1,5 @@
+use ::Result;
+
#[inline]
pub fn GX_BUFFER_DIM(w: u32, h: u32) {
(((h)<<16)|((w)&0xFFFF));
@@ -10,7 +12,7 @@ pub enum GX_TRANSFER_FORMAT
GX_TRANSFER_FMT_RGB8 = 1,
GX_TRANSFER_FMT_RGB565 = 2,
GX_TRANSFER_FMT_RGB5A1 = 3,
- GX_TRANSFER_FMT_RGBA4 = 4
+ GX_TRANSFER_FMT_RGBA4 = 4,
}
#[repr(C)]
@@ -18,7 +20,7 @@ pub enum GX_TRANSFER_SCALE
{
GX_TRANSFER_SCALE_NO = 0,
GX_TRANSFER_SCALE_X = 1,
- GX_TRANSFER_SCALE_Y = 2
+ GX_TRANSFER_SCALE_Y = 2,
}
#[repr(C)]
@@ -31,43 +33,62 @@ pub enum GX_FILL_CONTROL {
}
#[inline]
-pub fn GX_TRANSFER_FLIP_VERT(x) {
+pub fn GX_TRANSFER_FLIP_VERT(x: i32) {
((x)<<0);
}
#[inline]
-pub fn GX_TRANSFER_OUT_TILED(x) {
+pub fn GX_TRANSFER_OUT_TILED(x: i32) {
((x)<<1);
}
#[inline]
-pub fn GX_TRANSFER_RAW_COPY(x) {
- ((x)<<3)
+pub fn GX_TRANSFER_RAW_COPY(x: i32) {
+ ((x)<<3);
}
#[inline]
-pub fn GX_TRANSFER_IN_FORMAT(x) {
+pub fn GX_TRANSFER_IN_FORMAT(x: i32) {
((x)<<8);
}
#[inline]
-pub fn GX_TRANSFER_OUT_FORMAT(x) {
- ((x)<<12)
+pub fn GX_TRANSFER_OUT_FORMAT(x: i32) {
+ ((x)<<12);
}
#[inline]
-pub fn GX_TRANSFER_SCALING(x) {
+pub fn GX_TRANSFER_SCALING(x: i32) {
((x)<<24);
}
-use ctru::Result;
+#[inline]
+pub fn GX_CMDLIST_BIT0() {
+ (1u32<<(0));
+}
+#[inline]
+pub fn GX_CMNDLIST_FLUSH() {
+ (1u32<<(1));
+}
extern "C" {
- pub fn GX_RequestDma(gxbuf: *mut u32, src: *mut u32, dst: *mut u32, length: u32) -> Result;
- pub fn GX_SetCommandList_Last(gxbuf: *mut u32, buf0a: *mut u32, buf0s: u32, flags: u8) -> Result;
- pub fn GX_SetMemoryFill(gxbuf: *mut u32, buf0a: *mut u32, buf0v: u32, buf0e: *mut u32, width0: u16, buf1a: *mut u32, buf1v: u32, buf1e: *mut u32, width1: u16) -> Result;
- pub fn GX_SetDisplayTransfer(gxbuf: *mut u32, inadr: *mut u32, indim: u32, outadr: *mut u32, outdim: u32, flags: u32) -> Result;
- pub fn GX_SetTextureCopy(gxbuf: *mut u32, inadr: *mut u32, indim: u32, outadr: *mut u32, outdim: u32, size: u32, flags: u32) -> Result;
- pub fn GX_SetCommandList_First(gxbuf: *mut u32, buf0a: *mut u32, buf0s: u32, buf1a: *mut u32, buf1s: u32, buf2a: *mut u32, buf2s: u32) -> Result;
+ pub static mut gxCmdBuf: *mut u32;
+
+ pub fn GX_RequestDma(src: *mut u32, dst: *mut u32, length: u32)
+ -> Result;
+ pub fn GX_ProcessCommandList(buf0a: *mut u32, buf0s: u32, flags: u8)
+ -> Result;
+ pub fn GX_MemoryFill(buf0a: *mut u32, buf0v: u32, buf0e: *mut u32,
+ control0: u16, buf1a: *mut u32, buf1v: u32,
+ buf1e: *mut u32, control1: u16) -> Result;
+ pub fn GX_DisplayTransfer(inadr: *mut u32, indim: u32,
+ outadr: *mut u32, outdim: u32, flags: u32)
+ -> Result;
+ pub fn GX_TextureCopy(inadr: *mut u32, indim: u32, outadr: *mut u32,
+ outdim: u32, size: u32, flags: u32) -> Result;
+ pub fn GX_FlushCacheRegions(buf0a: *mut u32, buf0s: u32,
+ buf1a: *mut u32, buf1s: u32,
+ buf2a: *mut u32, buf2s: u32) -> Result;
}
+
diff --git a/ctru-sys/src/gpu/mod.rs b/ctru-sys/src/gpu/mod.rs
index 8d71046..2b9cb99 100644
--- a/ctru-sys/src/gpu/mod.rs
+++ b/ctru-sys/src/gpu/mod.rs
@@ -1,11 +1,5 @@
pub mod gpu;
pub mod gx;
pub mod registers;
-pub mod shader_program;
+pub mod shaderProgram;
pub mod shbin;
-
-use self::gpu::*;
-use self::gx::*;
-use self::registers::*;
-use self::shader_program::*;
-use self::shbin::*;
diff --git a/ctru-sys/src/gpu/registers.rs b/ctru-sys/src/gpu/registers.rs
index 739a50a..98b2a3b 100644
--- a/ctru-sys/src/gpu/registers.rs
+++ b/ctru-sys/src/gpu/registers.rs
@@ -1,3 +1,4 @@
+//Miscellaneous registers (0x000-0x03F)
pub const GPUREG_0000: i32 = 0x0000;
pub const GPUREG_0001: i32 = 0x0001;
pub const GPUREG_0002: i32 = 0x0002;
@@ -62,6 +63,8 @@ pub const GPUREG_003C: i32 = 0x003C;
pub const GPUREG_003D: i32 = 0x003D;
pub const GPUREG_003E: i32 = 0x003E;
pub const GPUREG_003F: i32 = 0x003F;
+
+//Rasterizer registers (0x040-0x07F)
pub const GPUREG_FACECULLING_CONFIG: i32 = 0x0040;
pub const GPUREG_0041: i32 = 0x0041;
pub const GPUREG_0042: i32 = 0x0042;
@@ -126,6 +129,8 @@ pub const GPUREG_007C: i32 = 0x007C;
pub const GPUREG_007D: i32 = 0x007D;
pub const GPUREG_007E: i32 = 0x007E;
pub const GPUREG_007F: i32 = 0x007F;
+
+//Texturing registers (0x080-0x0FF)
pub const GPUREG_TEXUNITS_CONFIG: i32 = 0x0080;
pub const GPUREG_0081: i32 = 0x0081;
pub const GPUREG_TEXUNIT0_DIM: i32 = 0x0082;
@@ -254,6 +259,8 @@ pub const GPUREG_TEXENV5_CONFIG4: i32 = 0x00FC;
pub const GPUREG_00FD: i32 = 0x00FD;
pub const GPUREG_00FE: i32 = 0x00FE;
pub const GPUREG_00FF: i32 = 0x00FF;
+
+//Framebuffer registers (0x100-0x13F)
pub const GPUREG_COLOROUTPUT_CONFIG: i32 = 0x0100;
pub const GPUREG_BLEND_CONFIG: i32 = 0x0101;
pub const GPUREG_COLORLOGICOP_CONFIG: i32 = 0x0102;
@@ -318,6 +325,8 @@ pub const GPUREG_013C: i32 = 0x013C;
pub const GPUREG_013D: i32 = 0x013D;
pub const GPUREG_013E: i32 = 0x013E;
pub const GPUREG_013F: i32 = 0x013F;
+
+//Fragment lighting registers (0x140-0x1FF)
pub const GPUREG_0140: i32 = 0x0140;
pub const GPUREG_0141: i32 = 0x0141;
pub const GPUREG_0142: i32 = 0x0142;
@@ -510,6 +519,8 @@ pub const GPUREG_01FC: i32 = 0x01FC;
pub const GPUREG_01FD: i32 = 0x01FD;
pub const GPUREG_01FE: i32 = 0x01FE;
pub const GPUREG_01FF: i32 = 0x01FF;
+
+//Geometry pipeline registers (0x200-0x27F)
pub const GPUREG_ATTRIBBUFFERS_LOC: i32 = 0x0200;
pub const GPUREG_ATTRIBBUFFERS_FORMAT_LOW: i32 = 0x0201;
pub const GPUREG_ATTRIBBUFFERS_FORMAT_HIGH: i32 = 0x0202;
@@ -638,6 +649,8 @@ pub const GPUREG_027C: i32 = 0x027C;
pub const GPUREG_027D: i32 = 0x027D;
pub const GPUREG_027E: i32 = 0x027E;
pub const GPUREG_027F: i32 = 0x027F;
+
+//Geometry shader registers (0x280-0x2AF)
pub const GPUREG_GSH_BOOLUNIFORM: i32 = 0x0280;
pub const GPUREG_GSH_INTUNIFORM_I0: i32 = 0x0281;
pub const GPUREG_GSH_INTUNIFORM_I1: i32 = 0x0282;
@@ -665,6 +678,8 @@ pub const GPUREG_GSH_OPDESCS_CONFIG: i32 = 0x02A5;
pub const GPUREG_GSH_OPDESCS_DATA: i32 = 0x02A6;
pub const GPUREG_02AE: i32 = 0x02AE;
pub const GPUREG_02AF: i32 = 0x02AF;
+
+//Vertex shader registers (0x2B0-0x2DF)
pub const GPUREG_VSH_BOOLUNIFORM: i32 = 0x02B0;
pub const GPUREG_VSH_INTUNIFORM_I0: i32 = 0x02B1;
pub const GPUREG_VSH_INTUNIFORM_I1: i32 = 0x02B2;
@@ -692,6 +707,8 @@ pub const GPUREG_VSH_OPDESCS_CONFIG: i32 = 0x02D5;
pub const GPUREG_VSH_OPDESCS_DATA: i32 = 0x02D6;
pub const GPUREG_02DE: i32 = 0x02DE;
pub const GPUREG_02DF: i32 = 0x02DF;
+
+//Unknown registers (0x2E0-0x2FF)
pub const GPUREG_02E0: i32 = 0x02E0;
pub const GPUREG_02E1: i32 = 0x02E1;
pub const GPUREG_02E2: i32 = 0x02E2;
@@ -723,4 +740,4 @@ pub const GPUREG_02FB: i32 = 0x02FB;
pub const GPUREG_02FC: i32 = 0x02FC;
pub const GPUREG_02FD: i32 = 0x02FD;
pub const GPUREG_02FE: i32 = 0x02FE;
-pub const GPUREG_02FF: i32 = 0x02FF
+pub const GPUREG_02FF: i32 = 0x02FF;
diff --git a/ctru-sys/src/gpu/shaderProgram.rs b/ctru-sys/src/gpu/shaderProgram.rs
new file mode 100644
index 0000000..f81f772
--- /dev/null
+++ b/ctru-sys/src/gpu/shaderProgram.rs
@@ -0,0 +1,89 @@
+use ::Result;
+use ::types::*;
+use gpu::shbin::*;
+
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed1 {
+ pub id: u32,
+ pub data: [u32; 3usize],
+}
+impl ::core::clone::Clone for Struct_Unnamed1 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed1 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type float24Uniform_s = Struct_Unnamed1;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed2 {
+ pub dvle: *mut DVLE_s,
+ pub boolUniforms: u16,
+ pub boolUniformMask: u16,
+ pub intUniforms: [u32; 4usize],
+ pub float24Uniforms: *mut float24Uniform_s,
+ pub intUniformMask: u8,
+ pub numFloat24Uniforms: u8,
+}
+impl ::core::clone::Clone for Struct_Unnamed2 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed2 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type shaderInstance_s = Struct_Unnamed2;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed3 {
+ pub vertexShader: *mut shaderInstance_s,
+ pub geometryShader: *mut shaderInstance_s,
+ pub geoShaderInputPermutation: [u32; 2usize],
+ pub geoShaderInputStride: u8,
+ pub geoShaderMode: u8,
+}
+impl ::core::clone::Clone for Struct_Unnamed3 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed3 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type shaderProgram_s = Struct_Unnamed3;
+#[derive(Clone, Copy)]
+#[repr(u32)]
+pub enum Enum_Unnamed4 {
+ GSH_NORMAL = 0,
+ GSH_PARTICLE = 1,
+ GSH_SUBDIVISION_LOOP = 2,
+ GSH_SUBDIVISION_CATMULL_CLARK = 3,
+}
+pub type geoShaderMode = Enum_Unnamed4;
+extern "C" {
+ pub fn shaderInstanceInit(si: *mut shaderInstance_s, dvle: *mut DVLE_s)
+ -> Result;
+ pub fn shaderInstanceFree(si: *mut shaderInstance_s) -> Result;
+ pub fn shaderInstanceSetBool(si: *mut shaderInstance_s,
+ id: i32, value: u8)
+ -> Result;
+ pub fn shaderInstanceGetBool(si: *mut shaderInstance_s,
+ id: i32, value: *mut u8)
+ -> Result;
+ pub fn shaderInstanceGetUniformLocation(si: *mut shaderInstance_s,
+ name:
+ *const u8)
+ -> s8;
+ pub fn shaderProgramInit(sp: *mut shaderProgram_s) -> Result;
+ pub fn shaderProgramFree(sp: *mut shaderProgram_s) -> Result;
+ pub fn shaderProgramSetVsh(sp: *mut shaderProgram_s, dvle: *mut DVLE_s)
+ -> Result;
+ pub fn shaderProgramSetGsh(sp: *mut shaderProgram_s, dvle: *mut DVLE_s,
+ stride: u8) -> Result;
+ pub fn shaderProgramSetGshInputPermutation(sp: *mut shaderProgram_s,
+ permutation: u64) -> Result;
+ pub fn shaderProgramSetGshMode(sp: *mut shaderProgram_s,
+ mode: geoShaderMode) -> Result;
+ pub fn shaderProgramConfigure(sp: *mut shaderProgram_s, sendVshCode: u8,
+ sendGshCode: u8) -> Result;
+ pub fn shaderProgramUse(sp: *mut shaderProgram_s) -> Result;
+}
diff --git a/ctru-sys/src/gpu/shader_program.rs b/ctru-sys/src/gpu/shader_program.rs
deleted file mode 100644
index bf373e1..0000000
--- a/ctru-sys/src/gpu/shader_program.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-use super::shbin::*;
-
-#[repr(C)]
-#[derive(Copy)]
-pub struct float24Uniform_s {
- id: u32,
- data: [u32; 3usize]
-}
-
-#[repr(C)]
-#[derive(Copy)]
-pub struct shaderInstance_s {
- pub dvle: *mut DVLE_s;
- pub boolUniforms: u16,
- pub intUniforms: [u32; 4usize],
- pub float24Uniforms: *mut float24Uniform_s,
- pub numFloat24Uniforms: u8,
-}
-
-#[repr(C)]
-#[derive(Copy)]
-pub struct shaderProgram_s {
- pub vertexShader: *mut shaderInstance_s,
- pub geometryShader: *mut shaderInstance_s,
- pub geometryShaderInputStride: u8,
-}
-
-use ctru::Result;
-
-
-extern "C" {
- pub fn shaderInstanceInit(si: *mut shaderInstance_s, dvle: *mut DVLE_s) -> Result;
- pub fn shaderInstanceFree(si: *mut shaderInstance_s) -> Result;
- pub fn shaderInstanceSetBool(si: *mut shaderInstance_s, id: ::libc::c_int, value: u8) -> Result;
- pub fn shaderInstanceGetBool(si: *mut shaderInstance_s, id: ::libc::c_int, value: *mut u8) -> Result;
- pub fn shaderInstanceGetUniformLocation(si: *mut shaderInstance_s, name: *const ::libc::c_char) -> Result;
- pub fn shaderProgramInit(sp: *mut shaderProgram_s) -> Result;
- pub fn shaderProgramFree(sp: *mut shaderProgram_s) -> Result;
- pub fn shaderProgramSetVsh(sp: *mut shaderProgram_s, dvle: *mut DVLE_s) -> Result;
- pub fn shaderProgramSetGsh(sp: *mut shaderProgram_s, dvle: *mut DVLE_s, stride: _u8) -> Result;
- pub fn shaderProgramUse(sp: *mut shaderProgram_s) -> Result;
-}
diff --git a/ctru-sys/src/gpu/shbin.rs b/ctru-sys/src/gpu/shbin.rs
index db400d9..1c5a453 100644
--- a/ctru-sys/src/gpu/shbin.rs
+++ b/ctru-sys/src/gpu/shbin.rs
@@ -1,105 +1,136 @@
-typedef enum{
- VERTEX_SHDR=GPU_VERTEX_SHADER,
- GEOMETRY_SHDR=GPU_GEOMETRY_SHADER
-}DVLE_type;
+use ::types::*;
-#[repr(C)]
-pub enum DVLE_type {
- VERTEX_SHDR=GPU_VERTEX_SHADER,
- GEOMETRY_SHDR=GPU_GEOMETRY_SHADER,
+#[derive(Clone, Copy)]
+#[repr(u32)]
+pub enum Enum_Unnamed1 {
+ VERTEX_SHDR = 0,
+ GEOMETRY_SHDR = 1,
}
-
-typedef enum{
- DVLE_CONST_BOOL=0x0,
- DVLE_CONST_u8=0x1,
- DVLE_CONST_FLOAT24=0x2,
-}DVLE_constantType;
-
-#[repr(C)]
-pub enum DVLE_constantType {
- DVLE_CONST_BOOL = 0x0,
- DVLE_CONST_u8 = 0x1,
- DVLE_CONST_FLOAT24 = 0x2,
+pub type DVLE_type = Enum_Unnamed1;
+#[derive(Clone, Copy)]
+#[repr(u32)]
+pub enum Enum_Unnamed2 {
+ DVLE_CONST_BOOL = 0,
+ DVLE_CONST_u8 = 1,
+ DVLE_CONST_FLOAT24 = 2,
}
-
-#[repr(C)]
-pub enum DVLE_outputAttribute_t {
- RESULT_POSITION = 0x0,
- RESULT_NORMALQUAT = 0x1,
- RESULT_COLOR = 0x2,
- RESULT_TEXCOORD0 = 0x3,
- RESULT_TEXCOORD0W = 0x4,
- RESULT_TEXCOORD1 = 0x5,
- RESULT_TEXCOORD2 = 0x6,
- RESULT_VIEW = 0x8
+pub type DVLE_constantType = Enum_Unnamed2;
+#[derive(Clone, Copy)]
+#[repr(u32)]
+pub enum Enum_Unnamed3 {
+ RESULT_POSITION = 0,
+ RESULT_NORMALQUAT = 1,
+ RESULT_COLOR = 2,
+ RESULT_TEXCOORD0 = 3,
+ RESULT_TEXCOORD0W = 4,
+ RESULT_TEXCOORD1 = 5,
+ RESULT_TEXCOORD2 = 6,
+ RESULT_VIEW = 8,
}
-
+pub type DVLE_outputAttribute_t = Enum_Unnamed3;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLP_s {
- codeSize: u32,
- codeData: *mut u32,
- opdescSize: u32,
- opcdescData: *mut u32
+pub struct Struct_Unnamed4 {
+ pub codeSize: u32,
+ pub codeData: *mut u32,
+ pub opdescSize: u32,
+ pub opcdescData: *mut u32,
}
-
+impl ::core::clone::Clone for Struct_Unnamed4 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed4 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLP_s = Struct_Unnamed4;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLE_constEntry_s {
- type: u16,
- id: u16,
- data: [u32; 4usize]
+pub struct Struct_Unnamed5 {
+ pub _type: u16,
+ pub id: u16,
+ pub data: [u32; 4usize],
}
-
+impl ::core::clone::Clone for Struct_Unnamed5 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed5 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLE_constEntry_s = Struct_Unnamed5;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLE_outEntry_s {
- type: u16,
- regID: u16,
- mask: u8,
- unk: [u8; 3usize]
+pub struct Struct_Unnamed6 {
+ pub _type: u16,
+ pub regID: u16,
+ pub mask: u8,
+ pub unk: [u8; 3usize],
}
-
+impl ::core::clone::Clone for Struct_Unnamed6 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed6 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLE_outEntry_s = Struct_Unnamed6;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLE_uniformEntry_s{
- symbolOffset: u32,
- startReg: u16,
- endReg: u16,
+pub struct Struct_Unnamed7 {
+ pub symbolOffset: u32,
+ pub startReg: u16,
+ pub endReg: u16,
}
-
+impl ::core::clone::Clone for Struct_Unnamed7 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed7 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLE_uniformEntry_s = Struct_Unnamed7;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLE_s {
- DVLE_type type: DVLE_type,
- DVLP_s* dvlp: *mut DVLP_s,
- mainOffset: u32,
- endmainOffset: u32,
- constTableSize: u32,
- constTableData: *mut DVLE_constEntry_s,
- outTableSize: u32,
- outTableData: *mut DVLE_outEntry_s,
- uniformTableSize: u32,
- uniformTableData: *mut DVLE_uniformEntry_s,
- symbolTableData: *mut u8,
- outmapMask: u8,
- outmapData: [u32; 8usize]
+pub struct Struct_Unnamed8 {
+ pub _type: DVLE_type,
+ pub dvlp: *mut DVLP_s,
+ pub mainOffset: u32,
+ pub endmainOffset: u32,
+ pub constTableSize: u32,
+ pub constTableData: *mut DVLE_constEntry_s,
+ pub outTableSize: u32,
+ pub outTableData: *mut DVLE_outEntry_s,
+ pub uniformTableSize: u32,
+ pub uniformTableData: *mut DVLE_uniformEntry_s,
+ pub symbolTableData: *mut u8,
+ pub outmapMask: u8,
+ pub outmapData: [u32; 8usize],
+ pub outmapMode: u32,
+ pub outmapClock: u32,
}
-
+impl ::core::clone::Clone for Struct_Unnamed8 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed8 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLE_s = Struct_Unnamed8;
#[repr(C)]
#[derive(Copy)]
-pub struct DVLB_s {
- numDVLE: u32,
- DVLP: DVLP_s,
- DVLE: *mut DVLE_s
+pub struct Struct_Unnamed9 {
+ pub numDVLE: u32,
+ pub DVLP: DVLP_s,
+ pub DVLE: *mut DVLE_s,
}
-
-use ctru::raw::types::*;
-
-
+impl ::core::clone::Clone for Struct_Unnamed9 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed9 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DVLB_s = Struct_Unnamed9;
extern "C" {
- pub fn DVLB_ParseFile(shbinData: *mut u32, shbinSize: u32) -> *mut DVLB_s;
- pub fn DVLB_Free(dvlb: *mut DVLB_s) -> ();
- pub fn DVLE_GetUniformRegister(dvle: *mut DVLE_s, name: *const u8) -> s8;
- pub fn DVLE_GenerateOutmap(dvle: *mut DVLE_s) -> ();
+ pub fn DVLB_ParseFile(shbinData: *mut u32, shbinSize: u32)
+ -> *mut DVLB_s;
+ pub fn DVLB_Free(dvlb: *mut DVLB_s);
+ pub fn DVLE_GetUniformRegister(dvle: *mut DVLE_s,
+ name: *const u8) -> s8;
+ pub fn DVLE_GenerateOutmap(dvle: *mut DVLE_s);
}
diff --git a/ctru-sys/src/ipc.rs b/ctru-sys/src/ipc.rs
new file mode 100644
index 0000000..390022d
--- /dev/null
+++ b/ctru-sys/src/ipc.rs
@@ -0,0 +1,10 @@
+//TODO: Implement static inline functions + solve the anonymous enum enigma
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum IPC_BufferRights {
+ IPC_BUFFER_R = 2,
+ IPC_BUFFER_W = 4,
+ IPC_BUFFER_RW = 6,
+}
+
diff --git a/ctru-sys/src/lib.rs b/ctru-sys/src/lib.rs
index 7f7c1c8..4b212a5 100644
--- a/ctru-sys/src/lib.rs
+++ b/ctru-sys/src/lib.rs
@@ -1,15 +1,25 @@
+/*
+ * C bindings generation:
+ * bindgen --sysroot=$DEVKITARM/arm-none-eabi -I$CTRULIB/include $CTRULIB/include/3ds.h
+ */
+
#![no_std]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(overflowing_literals)]
pub mod console;
+pub mod env;
pub mod gfx;
-pub mod linear;
+pub mod gpu;
+pub mod ipc;
+pub mod lock;
pub mod os;
pub mod sdmc;
pub mod srv;
pub mod svc;
+pub mod synchronization;
+pub mod thread;
pub mod types;
pub mod services;
@@ -22,7 +32,7 @@ pub type Handle = u32;
#[repr(u8)]
pub enum c_void {
__variant1,
- __variant2
+ __variant2,
}
pub type ThreadFunc = Option<extern "C" fn(arg1: *mut c_void) -> ()>;
diff --git a/ctru-sys/src/linear.rs b/ctru-sys/src/linear.rs
deleted file mode 100644
index e663439..0000000
--- a/ctru-sys/src/linear.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-use c_void;
-
-
-extern "C" {
- pub fn linearAlloc(size: i32) -> *mut c_void;
- pub fn linearMemAlign(size: i32, alignment: i32) -> *mut c_void;
- pub fn linearRealloc(mem: *mut c_void, size: i32) -> *mut c_void;
- pub fn linearFree(mem: *mut c_void) -> ();
- pub fn linearSpaceFree() -> u32;
-}
diff --git a/ctru-sys/src/lock.rs b/ctru-sys/src/lock.rs
new file mode 100644
index 0000000..6a9bd1b
--- /dev/null
+++ b/ctru-sys/src/lock.rs
@@ -0,0 +1,33 @@
+//<sys/lock.h> from devkitArm, needed for synchronization.rs to compile
+
+//TODO: I don't even know this thing looks really spooky
+
+pub type _LOCK_T = i32;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct___lock_t {
+ pub lock: _LOCK_T,
+ pub thread_tag: u32,
+ pub counter: u32,
+}
+impl ::core::clone::Clone for Struct___lock_t {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct___lock_t {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type _LOCK_RECURSIVE_T = Struct___lock_t;
+extern "C" {
+ pub fn __libc_lock_init(lock: *mut _LOCK_T);
+ pub fn __libc_lock_init_recursive(lock: *mut _LOCK_RECURSIVE_T);
+ pub fn __libc_lock_close(lock: *mut _LOCK_T);
+ pub fn __libc_lock_close_recursive(lock: *mut _LOCK_RECURSIVE_T);
+ pub fn __libc_lock_acquire(lock: *mut _LOCK_T);
+ pub fn __libc_lock_acquire_recursive(lock: *mut _LOCK_RECURSIVE_T);
+ pub fn __libc_lock_release(lock: *mut _LOCK_T);
+ pub fn __libc_lock_release_recursive(lock: *mut _LOCK_RECURSIVE_T);
+ pub fn __libc_lock_try_acquire(lock: *mut _LOCK_T)
+ -> i32;
+ pub fn __libc_lock_try_acquire_recursive(lock: *mut _LOCK_RECURSIVE_T)
+ -> i32;
+}
diff --git a/ctru-sys/src/os.rs b/ctru-sys/src/os.rs
index eaff6e2..7dbe3be 100644
--- a/ctru-sys/src/os.rs
+++ b/ctru-sys/src/os.rs
@@ -1,14 +1,53 @@
+//TODO: Fix Bindgen's issues again.
+
+use ::Result;
+use types::*;
+
#[inline]
pub fn SYSTEM_VERSION(major: i32, minor: i32, revision: i32) {
(((major)<<24)|((minor)<<16)|((revision)<<8));
}
-
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed1 {
+ MEMREGION_ALL = 0,
+ MEMREGION_APPLICATION = 1,
+ MEMREGION_SYSTEM = 2,
+ MEMREGION_BASE = 3,
+}
+pub type MemRegion = Enum_Unnamed1;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed2 {
+ pub build: u8,
+ pub minor: u8,
+ pub mainver: u8,
+ pub reserved_x3: u8,
+ pub region: u8,
+ pub reserved_x5: [u8; 3usize],
+}
+impl ::core::clone::Clone for Struct_Unnamed2 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed2 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type OS_VersionBin = Struct_Unnamed2;
extern "C" {
- pub fn osConvertVirtToPhys(vaddr: u32) -> u32;
- pub fn osConvertOldLINEARMemToNew(addr: u32) -> u32;
+ pub fn osConvertVirtToPhys(vaddr: *const ::c_void) -> u32;
+ pub fn osConvertOldLINEARMemToNew(vaddr: *const ::c_void)
+ -> *mut ::c_void;
pub fn osStrError(error: u32) -> *const u8;
- pub fn osGetFirmVersion() -> u32;
- pub fn osGetKernelVersion() -> u32;
+ pub fn osGetMemRegionUsed(region: MemRegion) -> s64;
pub fn osGetTime() -> u64;
+ pub fn osSetSpeedupEnable(enable: u8);
+ pub fn osGetSystemVersionData(nver_versionbin: *mut OS_VersionBin,
+ cver_versionbin: *mut OS_VersionBin)
+ -> Result;
+ pub fn osGetSystemVersionDataString(nver_versionbin: *mut OS_VersionBin,
+ cver_versionbin: *mut OS_VersionBin,
+ sysverstr:
+ *mut u8,
+ sysverstr_maxsize: u32) -> Result;
}
diff --git a/ctru-sys/src/services/ac.rs b/ctru-sys/src/services/ac.rs
index 0b07ec6..f23369f 100644
--- a/ctru-sys/src/services/ac.rs
+++ b/ctru-sys/src/services/ac.rs
@@ -1,9 +1,8 @@
-use ::{Handle, Result};
-
+use ::Result;
extern "C" {
pub fn acInit() -> Result;
- pub fn acExit() -> Result;
- pub fn ACU_GetWifiStatus(servhandle: *mut Handle, out: *mut u32) -> Result;
- pub fn ACU_WaitInternetConnection() -> Result;
+ pub fn acExit();
+ pub fn acWaitInternetConnection() -> Result;
+ pub fn ACU_GetWifiStatus(out: *mut u32) -> Result;
}
diff --git a/ctru-sys/src/services/am.rs b/ctru-sys/src/services/am.rs
index 340261f..971829e 100644
--- a/ctru-sys/src/services/am.rs
+++ b/ctru-sys/src/services/am.rs
@@ -1,30 +1,49 @@
-use ::c_void;
-use ::{Result, Handle};
+use ::{Handle, Result};
#[repr(C)]
-#[derive(Clone, Copy)]
-pub struct TitleList {
- titleID: u64,
- size: u64,
- titleVersion: u16,
- unknown2: [u8; 6usize]
+#[derive(Copy)]
+pub struct AM_TitleEntry {
+ pub titleID: u64,
+ pub size: u64,
+ pub version: u16,
+ pub unk: [u8; 6usize],
}
+impl ::core::clone::Clone for AM_TitleEntry {
+ fn clone(&self) -> Self { *self }
+}
+
+impl ::core::default::Default for AM_TitleEntry {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
extern "C" {
pub fn amInit() -> Result;
- pub fn amExit() -> Result;
+ pub fn amExit();
pub fn amGetSessionHandle() -> *mut Handle;
pub fn AM_GetTitleCount(mediatype: u8, count: *mut u32) -> Result;
- pub fn AM_GetTitleIdList(mediatype: u8, count: u32, titleIDs: *mut u64) -> Result;
+ pub fn AM_GetTitleIdList(mediatype: u8, count: u32, titleIDs: *mut u64)
+ -> Result;
pub fn AM_GetDeviceId(deviceID: *mut u32) -> Result;
- pub fn AM_ListTitles(mediatype: u8, titleCount: u32, titleIdList: *mut u64, titleList: *mut TitleList) -> Result;
- pub fn AM_StartCiaInstall(mediatype: u8, ciaHandle: *mut Handle) -> Result;
+ pub fn AM_ListTitles(mediatype: u8, titleCount: u32,
+ titleIdList: *mut u64, titleList: *mut AM_TitleEntry)
+ -> Result;
+ pub fn AM_StartCiaInstall(mediatype: u8, ciaHandle: *mut Handle)
+ -> Result;
pub fn AM_StartDlpChildCiaInstall(ciaHandle: *mut Handle) -> Result;
pub fn AM_CancelCIAInstall(ciaHandle: *mut Handle) -> Result;
- pub fn AM_FinishCiaInstall(mediatype: u8, ciaHandle: *mut Handle) -> Result;
+ pub fn AM_FinishCiaInstall(mediatype: u8, ciaHandle: *mut Handle)
+ -> Result;
pub fn AM_DeleteTitle(mediatype: u8, titleID: u64) -> Result;
pub fn AM_DeleteAppTitle(mediatype: u8, titleID: u64) -> Result;
- pub fn AM_InstallFIRM(titleID: u64) -> Result;
- pub fn AM_GetTitleProductCode(mediatype: u8, titleID: u64, productCode: *mut c_void) -> Result;
+ pub fn AM_InstallNativeFirm() -> Result;
+ pub fn AM_InstallFirm(titleID: u64) -> Result;
+ pub fn AM_GetTitleProductCode(mediatype: u8, titleID: u64,
+ productCode: *mut u8)
+ -> Result;
+ pub fn AM_GetCiaFileInfo(mediatype: u8, titleEntry: *mut AM_TitleEntry,
+ fileHandle: Handle) -> Result;
+ pub fn AM_InitializeExternalTitleDatabase(overwrite: u8) -> Result;
+ pub fn AM_QueryAvailableExternalTitleDatabase(available: *mut u8)
+ -> Result;
}
diff --git a/ctru-sys/src/services/apt.rs b/ctru-sys/src/services/apt.rs
index 4eba65f..a6ee0c0 100644
--- a/ctru-sys/src/services/apt.rs
+++ b/ctru-sys/src/services/apt.rs
@@ -1,125 +1,169 @@
-use ::{Handle, Result};
+use ::{Result, Handle};
use ::c_void;
-pub const RUNFLAG_APTWORKAROUND: u32 = 1;
-pub const RUNFLAG_APTREINIT: u32 = 2;
-
#[repr(C)]
+#[derive(Clone, Copy)]
pub enum NS_APPID {
- APPID_HOMEMENU = 0x101, // Home Menu
- APPID_CAMERA = 0x110, // Camera applet
- APPID_FRIENDS_LIST = 0x112, // Friends List applet
- APPID_GAME_NOTES = 0x113, // Game Notes applet
- APPID_WEB = 0x114, // Internet Browser
- APPID_INSTRUCTION_MANUAL = 0x115, // Instruction Manual applet
- APPID_NOTIFICATIONS = 0x116, // Notifications applet
- APPID_MIIVERSE = 0x117, // Miiverse applet
- APPID_APPLICATION = 0x300, // Application
- APPID_SOFTWARE_KEYBOARD = 0x401, // Software Keyboard
- APPID_APPLETED = 0x402, // appletEd
- APPID_PNOTE_AP = 0x404, // PNOTE_AP
- APPID_SNOTE_AP = 0x405, // SNOTE_AP
- APPID_ERROR = 0x406, // error
- APPID_MINT = 0x407, // mint
- APPID_EXTRAPAD = 0x408, // extrapad
- APPID_MEMOLIB = 0x409, // memolib
-} // cf http://3dbrew.org/wiki/NS_and_APT_Services#AppIDs
+ APPID_HOMEMENU = 0x101, // Home Menu
+ APPID_CAMERA = 0x110, // Camera applet
+ APPID_FRIENDS_LIST = 0x112, // Friends List applet
+ APPID_GAME_NOTES = 0x113, // Game Notes applet
+ APPID_WEB = 0x114, // Internet Browser
+ APPID_INSTRUCTION_MANUAL = 0x115, // Instruction Manual applet
+ APPID_NOTIFICATIONS = 0x116, // Notifications applet
+ APPID_MIIVERSE = 0x117, // Miiverse applet
+ APPID_MIIVERSE_POSTING = 0x118,
+ APPID_AMIIBO_SETTINGS = 0x119,
+ APPID_APPLICATION = 0x300, // Application
+ APPID_ESHOP = 0x301,
+ APPID_SOFTWARE_KEYBOARD = 0x401, // Software Keyboard
+ APPID_APPLETED = 0x402, // appletEd
+ APPID_PNOTE_AP = 0x404, // PNOTE_AP
+ APPID_SNOTE_AP = 0x405, // SNOTE_AP
+ APPID_ERROR = 0x406, // error
+ APPID_MINT = 0x407, // mint
+ APPID_EXTRAPAD = 0x408, // extrapad
+ APPID_MEMOLIB = 0x409, // memolib
+}
#[repr(C)]
-pub enum APP_STATUS {
- APP_NOTINITIALIZED,
- APP_RUNNING,
- APP_SUSPENDED,
- APP_EXITING,
- APP_SUSPENDING,
- APP_SLEEPMODE,
- APP_PREPARE_SLEEPMODE,
- APP_APPLETSTARTED,
- APP_APPLETCLOSED
+#[derive(Clone, Copy)]
+pub enum APT_AppStatus {
+ APP_NOTINITIALIZED = 0,
+ APP_RUNNING = 1,
+ APP_SUSPENDED = 2,
+ APP_EXITING = 3,
+ APP_SUSPENDING = 4,
+ APP_SLEEPMODE = 5,
+ APP_PREPARE_SLEEPMODE = 6,
+ APP_APPLETSTARTED = 7,
+ APP_APPLETCLOSED = 8,
}
#[repr(C)]
-pub enum APTSIGNAL {
- APTSIGNAL_HOMEBUTTON = 1,
- // 2: sleep-mode related?
- APTSIGNAL_PREPARESLEEP = 3,
- // 4: triggered when ptm:s GetShellStatus() returns 5.
- APTSIGNAL_ENTERSLEEP = 5,
- APTSIGNAL_WAKEUP = 6,
- APTSIGNAL_ENABLE = 7,
- APTSIGNAL_POWERBUTTON = 8,
- APTSIGNAL_UTILITY = 9,
- APTSIGNAL_SLEEPSYSTEM = 10,
- APTSIGNAL_ERROR = 11
+#[derive(Clone, Copy)]
+pub enum APT_Signal {
+ APTSIGNAL_HOMEBUTTON = 1,
+ APTSIGNAL_PREPARESLEEP = 3,
+ APTSIGNAL_ENTERSLEEP = 5,
+ APTSIGNAL_WAKEUP = 6,
+ APTSIGNAL_ENABLE = 7,
+ APTSIGNAL_POWERBUTTON = 8,
+ APTSIGNAL_UTILITY = 9,
+ APTSIGNAL_SLEEPSYSTEM = 10,
+ APTSIGNAL_ERROR = 11,
}
#[repr(C)]
-pub enum APTHOOK {
- APTHOOK_ONSUSPEND = 0,
- APTHOOK_ONRESTORE,
- APTHOOK_ONSLEEP,
- APTHOOK_ONWAKEUP,
- APTHOOK_ONEXIT,
-
- APTHOOK_COUNT,
+#[derive(Clone, Copy)]
+pub enum APT_HookType {
+ APTHOOK_ONSUSPEND = 0,
+ APTHOOK_ONRESTORE = 1,
+ APTHOOK_ONSLEEP = 2,
+ APTHOOK_ONWAKEUP = 3,
+ APTHOOK_ONEXIT = 4,
+ APTHOOK_COUNT = 5,
}
-type aptHookFn = Option<extern "C" fn(hook: i32, param: *mut c_void) -> ()>;
+pub type aptHookFn = Option<unsafe extern "C" fn(hook: APT_HookType, param: *mut c_void)>;
#[repr(C)]
-#[derive(Clone, Copy)]
+#[derive(Copy)]
pub struct aptHookCookie {
- next: *mut aptHookCookie,
- callback: aptHookFn,
- param: *mut c_void,
+ pub next: *mut aptHookCookie,
+ pub callback: aptHookFn,
+ pub param: *mut c_void,
+}
+impl ::core::clone::Clone for aptHookCookie {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for aptHookCookie {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
-
extern "C" {
pub static mut aptEvents: [Handle; 3usize];
-
+}
+extern "C" {
pub fn aptInit() -> Result;
- pub fn aptExit() -> ();
- pub fn aptOpenSession() -> ();
- pub fn aptCloseSession() -> ();
- pub fn aptSetStatus(status: APP_STATUS) -> ();
- pub fn aptGetStatus() -> APP_STATUS;
+ pub fn aptExit();
+ pub fn aptOpenSession();
+ pub fn aptCloseSession();
+ pub fn aptSetStatus(status: APT_AppStatus);
+ pub fn aptGetStatus() -> APT_AppStatus;
pub fn aptGetStatusPower() -> u32;
- pub fn aptSetStatusPower(status: u32) -> ();
- pub fn aptReturnToMenu() -> ();
- pub fn aptWaitStatusEvent() -> ();
- pub fn aptSignalReadyForSleep() -> ();
+ pub fn aptSetStatusPower(status: u32);
+ pub fn aptReturnToMenu();
+ pub fn aptWaitStatusEvent();
+ pub fn aptSignalReadyForSleep();
pub fn aptGetMenuAppID() -> NS_APPID;
pub fn aptMainLoop() -> u8;
- pub fn APT_GetLockHandle(handle: *mut Handle, flags: u16, lockHandle: *mut Handle) -> Result;
- pub fn APT_Initialize(handle: *mut Handle, appId: NS_APPID, eventHandle1: *mut Handle, eventHandle2: *mut Handle) -> Result;
- pub fn APT_HardwareResetAsync(handle: *mut Handle) -> Result;
- pub fn APT_Enable(handle: *mut Handle, a: u32) -> Result;
- pub fn APT_GetAppletManInfo(handle: *mut Handle, inval: u8, outval8: *mut u8, outval32: *mut u32, menu_appid: *mut NS_APPID, active_appid: *mut NS_APPID) -> Result;
- pub fn APT_PrepareToJumpToHomeMenu(handle: *mut Handle) -> Result;
- pub fn APT_JumpToHomeMenu(handle: *mut Handle, a: u32, b: u32, c: u32) -> Result;
- pub fn APT_IsRegistered(handle: *mut Handle, appID: NS_APPID, out: *mut u8) -> Result;
- pub fn APT_InquireNotification(handle: *mut Handle, appID: u32, signalType: *mut u8) -> Result;
- pub fn APT_NotifyToWait(handle: *mut Handle, appID: NS_APPID) -> Result;
- pub fn APT_AppletUtility(handle: *mut Handle, out: *mut u32, a: u32, size1: u32, buf1: *mut u8, size2: u32, buf2: *mut u8) -> Result;
- pub fn APT_GlanceParameter(handle: *mut Handle, appID: NS_APPID, bufferSize: u32, buffer: *mut u32, actualSize: *mut u32, signalType: *mut u8) -> Result;
- pub fn APT_ReceiveParameter(handle: *mut Handle, appID: NS_APPID, bufferSize: u32, buffer: *mut u32, actualSize: *mut u32, signalType: *mut u8) -> Result;
- pub fn APT_SendParameter(handle: *mut Handle, src_appID: NS_APPID, dst_appID: NS_APPID, bufferSize: u32, buffer: *mut u32, paramhandle: Handle, signalType: u8) -> Result;
- pub fn APT_SendCaptureBufferInfo(handle: *mut Handle, bufferSize: u32, buffer: *mut u32) -> Result;
- pub fn APT_ReplySleepQuery(handle: *mut Handle, appID: NS_APPID, a: u32) -> Result;
- pub fn APT_ReplySleepNotificationComplete(handle: *mut Handle, appID: NS_APPID) -> Result;
- pub fn APT_PrepareToCloseApplication(handle: *mut Handle, a: u8) -> Result;
- pub fn APT_CloseApplication(handle: *mut Handle, a: u32, b: u32, c: u32) -> Result;
- pub fn APT_SetAppCpuTimeLimit(handle: *mut Handle, percent: u32) -> Result;
- pub fn APT_GetAppCpuTimeLimit(handle: *mut Handle, percent: *mut u32) -> Result;
- pub fn APT_CheckNew3DS_Application(handle: *mut Handle, out: *mut u8) -> Result;
- pub fn APT_CheckNew3DS_System(handle: *mut Handle, out: *mut u8) -> Result;
- pub fn APT_CheckNew3DS(handle: *mut Handle, out: *mut u8) -> Result;
- pub fn APT_PrepareToDoAppJump(handle: *mut Handle, flags: u8, programID: u64, mediatype: u8) -> Result;
- pub fn APT_DoAppJump(handle: *mut Handle, NSbuf0Size: u32, NSbuf1Size: u32, NSbuf0Ptr: *mut u8, NSbuf1Ptr: *mut u8) -> Result;
- pub fn APT_PrepareToStartLibraryApplet(handle: *mut Handle, appID: NS_APPID) -> Result;
- pub fn APT_StartLibraryApplet(handle: *mut Handle, appID: NS_APPID, inhandle: Handle, parambuf: *mut u32, parambufsize: u32) -> Result;
- pub fn APT_LaunchLibraryApplet(appID: NS_APPID, inhandle: Handle, parambuf: *mut u32, parambufsize: u32) -> Result;
- pub fn APT_PrepareToStartSystemApplet(handle: *mut Handle, appID: NS_APPID) -> Result;
- pub fn APT_StartSystemApplet(handle: *mut Handle, appID: NS_APPID, bufSize: u32, applHandle: Handle, buf: *mut u8) -> Result;
+ pub fn aptHook(cookie: *mut aptHookCookie, callback: aptHookFn,
+ param: *mut c_void);
+ pub fn aptUnhook(cookie: *mut aptHookCookie);
+ pub fn APT_GetLockHandle(flags: u16, lockHandle: *mut Handle) -> Result;
+ pub fn APT_Initialize(appId: NS_APPID, eventHandle1: *mut Handle,
+ eventHandle2: *mut Handle) -> Result;
+ pub fn APT_Finalize(appId: NS_APPID) -> Result;
+ pub fn APT_HardwareResetAsync() -> Result;
+ pub fn APT_Enable(a: u32) -> Result;
+ pub fn APT_GetAppletManInfo(inval: u8, outval8: *mut u8,
+ outval32: *mut u32,
+ menu_appid: *mut NS_APPID,
+ active_appid: *mut NS_APPID) -> Result;
+ pub fn APT_GetAppletInfo(appID: NS_APPID, pProgramID: *mut u64,
+ pMediaType: *mut u8, pRegistered: *mut u8,
+ pLoadState: *mut u8, pAttributes: *mut u32)
+ -> Result;
+ pub fn APT_GetAppletProgramInfo(id: u32, flags: u32,
+ titleversion: *mut u16) -> Result;
+ pub fn APT_GetProgramID(pProgramID: *mut u64) -> Result;
+ pub fn APT_PrepareToJumpToHomeMenu() -> Result;
+ pub fn APT_JumpToHomeMenu(param: *const u8, paramSize: usize,
+ handle: Handle) -> Result;
+ pub fn APT_PrepareToJumpToApplication(a: u32) -> Result;
+ pub fn APT_JumpToApplication(param: *const u8, paramSize: usize,
+ handle: Handle) -> Result;
+ pub fn APT_IsRegistered(appID: NS_APPID, out: *mut u8) -> Result;
+ pub fn APT_InquireNotification(appID: u32, signalType: *mut APT_Signal)
+ -> Result;
+ pub fn APT_NotifyToWait(appID: NS_APPID) -> Result;
+ pub fn APT_AppletUtility(out: *mut u32, a: u32, size1: u32,
+ buf1: *mut u8, size2: u32, buf2: *mut u8)
+ -> Result;
+ pub fn APT_GlanceParameter(appID: NS_APPID, bufferSize: u32,
+ buffer: *mut u32, actualSize: *mut u32,
+ signalType: *mut u8) -> Result;
+ pub fn APT_ReceiveParameter(appID: NS_APPID, bufferSize: u32,
+ buffer: *mut u32, actualSize: *mut u32,
+ signalType: *mut u8) -> Result;
+ pub fn APT_SendParameter(src_appID: NS_APPID, dst_appID: NS_APPID,
+ bufferSize: u32, buffer: *mut u32,
+ paramhandle: Handle, signalType: u8) -> Result;
+ pub fn APT_SendCaptureBufferInfo(bufferSize: u32, buffer: *mut u32)
+ -> Result;
+ pub fn APT_ReplySleepQuery(appID: NS_APPID, a: u32) -> Result;
+ pub fn APT_ReplySleepNotificationComplete(appID: NS_APPID) -> Result;
+ pub fn APT_PrepareToCloseApplication(a: u8) -> Result;
+ pub fn APT_CloseApplication(param: *const u8, paramSize: usize,
+ handle: Handle) -> Result;
+ pub fn APT_SetAppCpuTimeLimit(percent: u32) -> Result;
+ pub fn APT_GetAppCpuTimeLimit(percent: *mut u32) -> Result;
+ pub fn APT_CheckNew3DS_Application(out: *mut u8) -> Result;
+ pub fn APT_CheckNew3DS_System(out: *mut u8) -> Result;
+ pub fn APT_CheckNew3DS(out: *mut u8) -> Result;
+ pub fn APT_PrepareToDoAppJump(flags: u8, programID: u64, mediatype: u8)
+ -> Result;
+ pub fn APT_DoAppJump(NSbuf0Size: u32, NSbuf1Size: u32,
+ NSbuf0Ptr: *mut u8, NSbuf1Ptr: *mut u8) -> Result;
+ pub fn APT_PrepareToStartLibraryApplet(appID: NS_APPID) -> Result;
+ pub fn APT_StartLibraryApplet(appID: NS_APPID, inhandle: Handle,
+ parambuf: *mut u32, parambufsize: u32)
+ -> Result;
+ pub fn APT_LaunchLibraryApplet(appID: NS_APPID, inhandle: Handle,
+ parambuf: *mut u32, parambufsize: u32)
+ -> Result;
+ pub fn APT_PrepareToStartSystemApplet(appID: NS_APPID) -> Result;
+ pub fn APT_StartSystemApplet(appID: NS_APPID, bufSize: u32,
+ applHandle: Handle, buf: *mut u8) -> Result;
}
diff --git a/ctru-sys/src/services/cam.rs b/ctru-sys/src/services/cam.rs
new file mode 100644
index 0000000..e9ef4f6
--- /dev/null
+++ b/ctru-sys/src/services/cam.rs
@@ -0,0 +1,410 @@
+// TODO: Determine if anonymous enums are properly represented (they probably aren't)
+
+use ::{Handle, Result};
+use ::c_void;
+use ::types::*;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed1 {
+ PORT_NONE = 0,
+ PORT_CAM1 = 1,
+ PORT_CAM2 = 2,
+ PORT_BOTH = 3,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed2 {
+ SELECT_NONE = 0,
+ SELECT_OUT1 = 1,
+ SELECT_IN1 = 2,
+ SELECT_OUT2 = 4,
+ SELECT_IN1_OUT1 = 3,
+ SELECT_OUT1_OUT2 = 5,
+ SELECT_IN1_OUT2 = 6,
+ SELECT_ALL = 7,
+}
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed3 {
+ CONTEXT_NONE = 0,
+ CONTEXT_A = 1,
+ CONTEXT_B = 2,
+ CONTEXT_BOTH = 3,
+}
+
+pub type CAMU_Context = Enum_Unnamed3;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed4 {
+ FLIP_NONE = 0,
+ FLIP_HORIZONTAL = 1,
+ FLIP_VERTICAL = 2,
+ FLIP_REVERSE = 3,
+}
+pub type CAMU_Flip = Enum_Unnamed4;
+
+pub const SIZE_CTR_BOTTOM_LCD: Enum_Unnamed5 = Enum_Unnamed5::SIZE_QVGA;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed5 {
+ SIZE_VGA = 0,
+ SIZE_QVGA = 1,
+ SIZE_QQVGA = 2,
+ SIZE_CIF = 3,
+ SIZE_QCIF = 4,
+ SIZE_DS_LCD = 5,
+ SIZE_DS_LCDx4 = 6,
+ SIZE_CTR_TOP_LCD = 7,
+}
+pub type CAMU_Size = Enum_Unnamed5;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum CAMU_FrameRate {
+ FRAME_RATE_15 = 0,
+ FRAME_RATE_15_TO_5 = 1,
+ FRAME_RATE_15_TO_2 = 2,
+ FRAME_RATE_10 = 3,
+ FRAME_RATE_8_5 = 4,
+ FRAME_RATE_5 = 5,
+ FRAME_RATE_20 = 6,
+ FRAME_RATE_20_TO_5 = 7,
+ FRAME_RATE_30 = 8,
+ FRAME_RATE_30_TO_5 = 9,
+ FRAME_RATE_15_TO_10 = 10,
+ FRAME_RATE_20_TO_10 = 11,
+ FRAME_RATE_30_TO_10 = 12,
+}
+
+pub const WHITE_BALANCE_NORMAL: Enum_Unnamed7 =
+ Enum_Unnamed7::WHITE_BALANCE_AUTO;
+pub const WHITE_BALANCE_TUNGSTEN: Enum_Unnamed7 =
+ Enum_Unnamed7::WHITE_BALANCE_3200K;
+pub const WHITE_BALANCE_WHITE_FLUORESCENT_LIGHT: Enum_Unnamed7 =
+ Enum_Unnamed7::WHITE_BALANCE_4150K;
+pub const WHITE_BALANCE_DAYLIGHT: Enum_Unnamed7 =
+ Enum_Unnamed7::WHITE_BALANCE_5200K;
+pub const WHITE_BALANCE_CLOUDY: Enum_Unnamed7 =
+ Enum_Unnamed7::WHITE_BALANCE_6000K;
+pub const WHITE_BALANCE_HORIZON: Enum_Unnamed7 =
+ Enum_Unnamed7::WHITE_BALANCE_6000K;
+pub const WHITE_BALANCE_SHADE: Enum_Unnamed7 =
+ Enum_Unnamed7::WHITE_BALANCE_7000K;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed7 {
+ WHITE_BALANCE_AUTO = 0,
+ WHITE_BALANCE_3200K = 1,
+ WHITE_BALANCE_4150K = 2,
+ WHITE_BALANCE_5200K = 3,
+ WHITE_BALANCE_6000K = 4,
+ WHITE_BALANCE_7000K = 5,
+}
+pub type CAMU_WhiteBalance = Enum_Unnamed7;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed8 {
+ PHOTO_MODE_NORMAL = 0,
+ PHOTO_MODE_PORTRAIT = 1,
+ PHOTO_MODE_LANDSCAPE = 2,
+ PHOTO_MODE_NIGHTVIEW = 3,
+ PHOTO_MODE_LETTER = 4,
+}
+pub type CAMU_PhotoMode = Enum_Unnamed8;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed9 {
+ EFFECT_NONE = 0,
+ EFFECT_MONO = 1,
+ EFFECT_SEPIA = 2,
+ EFFECT_NEGATIVE = 3,
+ EFFECT_NEGAFILM = 4,
+ EFFECT_SEPIA01 = 5,
+}
+pub type CAMU_Effect = Enum_Unnamed9;
+pub const CONTRAST_LOW: Enum_Unnamed10 = Enum_Unnamed10::CONTRAST_PATTERN_05;
+pub const CONTRAST_NORMAL: Enum_Unnamed10 =
+ Enum_Unnamed10::CONTRAST_PATTERN_06;
+pub const CONTRAST_HIGH: Enum_Unnamed10 = Enum_Unnamed10::CONTRAST_PATTERN_07;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed10 {
+ CONTRAST_PATTERN_01 = 0,
+ CONTRAST_PATTERN_02 = 1,
+ CONTRAST_PATTERN_03 = 2,
+ CONTRAST_PATTERN_04 = 3,
+ CONTRAST_PATTERN_05 = 4,
+ CONTRAST_PATTERN_06 = 5,
+ CONTRAST_PATTERN_07 = 6,
+ CONTRAST_PATTERN_08 = 7,
+ CONTRAST_PATTERN_09 = 8,
+ CONTRAST_PATTERN_10 = 9,
+ CONTRAST_PATTERN_11 = 10,
+}
+pub type CAMU_Contrast = Enum_Unnamed10;
+pub const LENS_CORRECTION_DARK: Enum_Unnamed11 =
+ Enum_Unnamed11::LENS_CORRECTION_OFF;
+pub const LENS_CORRECTION_NORMAL: Enum_Unnamed11 =
+ Enum_Unnamed11::LENS_CORRECTION_ON_70;
+pub const LENS_CORRECTION_BRIGHT: Enum_Unnamed11 =
+ Enum_Unnamed11::LENS_CORRECTION_ON_90;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed11 {
+ LENS_CORRECTION_OFF = 0,
+ LENS_CORRECTION_ON_70 = 1,
+ LENS_CORRECTION_ON_90 = 2,
+}
+pub type CAMU_LensCorrection = Enum_Unnamed11;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed12 { OUTPUT_YUV_422 = 0, OUTPUT_RGB_565 = 1, }
+pub type CAMU_OutputFormat = Enum_Unnamed12;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed13 {
+ SHUTTER_SOUND_TYPE_NORMAL = 0,
+ SHUTTER_SOUND_TYPE_MOVIE = 1,
+ SHUTTER_SOUND_TYPE_MOVIE_END = 2,
+}
+pub type CAMU_ShutterSoundType = Enum_Unnamed13;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed14 {
+ pub aeBaseTarget: s16,
+ pub kRL: s16,
+ pub kGL: s16,
+ pub kBL: s16,
+ pub ccmPosition: s16,
+ pub awbCcmL9Right: u16,
+ pub awbCcmL9Left: u16,
+ pub awbCcmL10Right: u16,
+ pub awbCcmL10Left: u16,
+ pub awbX0Right: u16,
+ pub awbX0Left: u16,
+}
+impl ::core::clone::Clone for Struct_Unnamed14 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed14 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type CAMU_ImageQualityCalibrationData = Struct_Unnamed14;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed15 {
+ pub isValidRotationXY: u8,
+ pub padding: [u8; 3usize],
+ pub scale: f32,
+ pub rotationZ: f32,
+ pub translationX: f32,
+ pub translationY: f32,
+ pub rotationX: f32,
+ pub rotationY: f32,
+ pub angleOfViewRight: f32,
+ pub angleOfViewLeft: f32,
+ pub distanceToChart: f32,
+ pub distanceCameras: f32,
+ pub imageWidth: s16,
+ pub imageHeight: s16,
+ pub reserved: [u8; 16usize],
+}
+impl ::core::clone::Clone for Struct_Unnamed15 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed15 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type CAMU_StereoCameraCalibrationData = Struct_Unnamed15;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed16 {
+ pub camera: u8,
+ pub exposure: s8,
+ pub whiteBalance: u8,
+ pub sharpness: s8,
+ pub autoExposureOn: u8,
+ pub autoWhiteBalanceOn: u8,
+ pub frameRate: u8,
+ pub photoMode: u8,
+ pub contrast: u8,
+ pub lensCorrection: u8,
+ pub noiseFilterOn: u8,
+ pub padding: u8,
+ pub autoExposureWindowX: s16,
+ pub autoExposureWindowY: s16,
+ pub autoExposureWindowWidth: s16,
+ pub autoExposureWindowHeight: s16,
+ pub autoWhiteBalanceWindowX: s16,
+ pub autoWhiteBalanceWindowY: s16,
+ pub autoWhiteBalanceWindowWidth: s16,
+ pub autoWhiteBalanceWindowHeight: s16,
+}
+impl ::core::clone::Clone for Struct_Unnamed16 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed16 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type CAMU_PackageParameterCameraSelect = Struct_Unnamed16;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed17 {
+ pub camera: u8,
+ pub context: u8,
+ pub flip: u8,
+ pub effect: u8,
+ pub size: u8,
+}
+impl ::core::clone::Clone for Struct_Unnamed17 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed17 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type CAMU_PackageParameterContext = Struct_Unnamed17;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed18 {
+ pub camera: u8,
+ pub context: u8,
+ pub flip: u8,
+ pub effect: u8,
+ pub width: s16,
+ pub height: s16,
+ pub cropX0: s16,
+ pub cropY0: s16,
+ pub cropX1: s16,
+ pub cropY1: s16,
+}
+impl ::core::clone::Clone for Struct_Unnamed18 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed18 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type CAMU_PackageParameterContextDetail = Struct_Unnamed18;
+
+use services::y2r::Y2RU_StandardCoefficient;
+extern "C" {
+ pub fn camInit() -> Result;
+ pub fn camExit();
+ pub fn CAMU_StartCapture(port: u32) -> Result;
+ pub fn CAMU_StopCapture(port: u32) -> Result;
+ pub fn CAMU_IsBusy(busy: *mut u8, port: u32) -> Result;
+ pub fn CAMU_ClearBuffer(port: u32) -> Result;
+ pub fn CAMU_GetVsyncInterruptEvent(event: *mut Handle, port: u32)
+ -> Result;
+ pub fn CAMU_GetBufferErrorInterruptEvent(event: *mut Handle, port: u32)
+ -> Result;
+ pub fn CAMU_SetReceiving(event: *mut Handle,
+ dst: *mut c_void, port: u32,
+ imageSize: u32, transferUnit: s16) -> Result;
+ pub fn CAMU_IsFinishedReceiving(finishedReceiving: *mut u8, port: u32)
+ -> Result;
+ pub fn CAMU_SetTransferLines(port: u32, lines: s16, width: s16,
+ height: s16) -> Result;
+ pub fn CAMU_GetMaxLines(maxLines: *mut s16, width: s16, height: s16)
+ -> Result;
+ pub fn CAMU_SetTransferBytes(port: u32, bytes: u32, width: s16,
+ height: s16) -> Result;
+ pub fn CAMU_GetTransferBytes(transferBytes: *mut u32, port: u32)
+ -> Result;
+ pub fn CAMU_GetMaxBytes(maxBytes: *mut u32, width: s16, height: s16)
+ -> Result;
+ pub fn CAMU_SetTrimming(port: u32, trimming: u8) -> Result;
+ pub fn CAMU_IsTrimming(trimming: *mut u8, port: u32) -> Result;
+ pub fn CAMU_SetTrimmingParams(port: u32, xStart: s16, yStart: s16,
+ xEnd: s16, yEnd: s16) -> Result;
+ pub fn CAMU_GetTrimmingParams(xStart: *mut s16, yStart: *mut s16,
+ xEnd: *mut s16, yEnd: *mut s16, port: u32)
+ -> Result;
+ pub fn CAMU_SetTrimmingParamsCenter(port: u32, trimWidth: s16,
+ trimHeight: s16, camWidth: s16,
+ camHeight: s16) -> Result;
+ pub fn CAMU_Activate(select: u32) -> Result;
+ pub fn CAMU_SwitchContext(select: u32, context: CAMU_Context) -> Result;
+ pub fn CAMU_SetExposure(select: u32, exposure: s8) -> Result;
+ pub fn CAMU_SetWhiteBalance(select: u32, whiteBalance: CAMU_WhiteBalance)
+ -> Result;
+ pub fn CAMU_SetWhiteBalanceWithoutBaseUp(select: u32,
+ whiteBalance: CAMU_WhiteBalance)
+ -> Result;
+ pub fn CAMU_SetSharpness(select: u32, sharpness: s8) -> Result;
+ pub fn CAMU_SetAutoExposure(select: u32, autoExposure: u8) -> Result;
+ pub fn CAMU_IsAutoExposure(autoExposure: *mut u8, select: u32) -> Result;
+ pub fn CAMU_SetAutoWhiteBalance(select: u32, autoWhiteBalance: u8)
+ -> Result;
+ pub fn CAMU_IsAutoWhiteBalance(autoWhiteBalance: *mut u8, select: u32)
+ -> Result;
+ pub fn CAMU_FlipImage(select: u32, flip: CAMU_Flip,
+ context: CAMU_Context) -> Result;
+ pub fn CAMU_SetDetailSize(select: u32, width: s16, height: s16,
+ cropX0: s16, cropY0: s16, cropX1: s16,
+ cropY1: s16, context: CAMU_Context) -> Result;
+ pub fn CAMU_SetSize(select: u32, size: CAMU_Size, context: CAMU_Context)
+ -> Result;
+ pub fn CAMU_SetFrameRate(select: u32, frameRate: CAMU_FrameRate)
+ -> Result;
+ pub fn CAMU_SetPhotoMode(select: u32, photoMode: CAMU_PhotoMode)
+ -> Result;
+ pub fn CAMU_SetEffect(select: u32, effect: CAMU_Effect,
+ context: CAMU_Context) -> Result;
+ pub fn CAMU_SetContrast(select: u32, contrast: CAMU_Contrast) -> Result;
+ pub fn CAMU_SetLensCorrection(select: u32,
+ lensCorrection: CAMU_LensCorrection)
+ -> Result;
+ pub fn CAMU_SetOutputFormat(select: u32, format: CAMU_OutputFormat,
+ context: CAMU_Context) -> Result;
+ pub fn CAMU_SetAutoExposureWindow(select: u32, x: s16, y: s16,
+ width: s16, height: s16) -> Result;
+ pub fn CAMU_SetAutoWhiteBalanceWindow(select: u32, x: s16, y: s16,
+ width: s16, height: s16) -> Result;
+ pub fn CAMU_SetNoiseFilter(select: u32, noiseFilter: u8) -> Result;
+ pub fn CAMU_SynchronizeVsyncTiming(select1: u32, select2: u32)
+ -> Result;
+ pub fn CAMU_GetLatestVsyncTiming(timing: *mut s64, port: u32, past: u32)
+ -> Result;
+ pub fn CAMU_GetStereoCameraCalibrationData(data:
+ *mut CAMU_StereoCameraCalibrationData)
+ -> Result;
+ pub fn CAMU_SetStereoCameraCalibrationData(data:
+ CAMU_StereoCameraCalibrationData)
+ -> Result;
+ pub fn CAMU_WriteRegisterI2c(select: u32, addr: u16, data: u16)
+ -> Result;
+ pub fn CAMU_WriteMcuVariableI2c(select: u32, addr: u16, data: u16)
+ -> Result;
+ pub fn CAMU_ReadRegisterI2cExclusive(data: *mut u16, select: u32,
+ addr: u16) -> Result;
+ pub fn CAMU_ReadMcuVariableI2cExclusive(data: *mut u16, select: u32,
+ addr: u16) -> Result;
+ pub fn CAMU_SetImageQualityCalibrationData(data:
+ CAMU_ImageQualityCalibrationData)
+ -> Result;
+ pub fn CAMU_GetImageQualityCalibrationData(data:
+ *mut CAMU_ImageQualityCalibrationData)
+ -> Result;
+ pub fn CAMU_SetPackageParameterWithoutContext(param:
+ CAMU_PackageParameterCameraSelect)
+ -> Result;
+ pub fn CAMU_SetPackageParameterWithContext(param:
+ CAMU_PackageParameterContext)
+ -> Result;
+ pub fn CAMU_SetPackageParameterWithContextDetail(param:
+ CAMU_PackageParameterContextDetail)
+ -> Result;
+ pub fn CAMU_GetSuitableY2rStandardCoefficient(coefficient:
+ *mut Y2RU_StandardCoefficient)
+ -> Result;
+ pub fn CAMU_PlayShutterSound(sound: CAMU_ShutterSoundType) -> Result;
+ pub fn CAMU_DriverInitialize() -> Result;
+ pub fn CAMU_DriverFinalize() -> Result;
+ pub fn CAMU_GetActivatedCamera(select: *mut u32) -> Result;
+ pub fn CAMU_GetSleepCamera(select: *mut u32) -> Result;
+ pub fn CAMU_SetSleepCamera(select: u32) -> Result;
+ pub fn CAMU_SetBrightnessSynchronization(brightnessSynchronization: u8)
+ -> Result;
+}
diff --git a/ctru-sys/src/services/cfgnor.rs b/ctru-sys/src/services/cfgnor.rs
index 4883642..c2c1e44 100644
--- a/ctru-sys/src/services/cfgnor.rs
+++ b/ctru-sys/src/services/cfgnor.rs
@@ -1,10 +1,14 @@
use ::Result;
extern "C" {
+ pub fn cfgnorInit(value: u8) -> Result;
+ pub fn cfgnorExit();
+ pub fn cfgnorDumpFlash(buf: *mut u32, size: u32) -> Result;
+ pub fn cfgnorWriteFlash(buf: *mut u32, size: u32) -> Result;
pub fn CFGNOR_Initialize(value: u8) -> Result;
pub fn CFGNOR_Shutdown() -> Result;
- pub fn CFGNOR_ReadData(offset: u32, buf: *mut u32, size: u32) -> Result;
- pub fn CFGNOR_WriteData(offset: u32, buf: *mut u32, size: u32) -> Result;
- pub fn CFGNOR_DumpFlash(buf: *mut u32, size: u32) -> Result;
- pub fn CFGNOR_WriteFlash(buf: *mut u32, size: u32) -> Result;
+ pub fn CFGNOR_ReadData(offset: u32, buf: *mut u32, size: u32)
+ -> Result;
+ pub fn CFGNOR_WriteData(offset: u32, buf: *mut u32, size: u32)
+ -> Result;
}
diff --git a/ctru-sys/src/services/cfgu.rs b/ctru-sys/src/services/cfgu.rs
index 4c51db4..f1663f0 100644
--- a/ctru-sys/src/services/cfgu.rs
+++ b/ctru-sys/src/services/cfgu.rs
@@ -1,15 +1,46 @@
use ::Result;
+#[repr(C)]
+#[derive(Clone, Copy)]
+pub enum CFG_Region {
+ CFG_REGION_JPN = 0,
+ CFG_REGION_USA = 1,
+ CFG_REGION_EUR = 2,
+ CFG_REGION_AUS = 3,
+ CFG_REGION_CHN = 4,
+ CFG_REGION_KOR = 5,
+ CFG_REGION_TWN = 6,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy)]
+pub enum CFG_Language {
+ CFG_LANGUAGE_JP = 0,
+ CFG_LANGUAGE_EN = 1,
+ CFG_LANGUAGE_FR = 2,
+ CFG_LANGUAGE_DE = 3,
+ CFG_LANGUAGE_IT = 4,
+ CFG_LANGUAGE_ES = 5,
+ CFG_LANGUAGE_ZH = 6,
+ CFG_LANGUAGE_KO = 7,
+ CFG_LANGUAGE_NL = 8,
+ CFG_LANGUAGE_PT = 9,
+ CFG_LANGUAGE_RU = 10,
+ CFG_LANGUAGE_TW = 11,
+}
+
extern "C" {
- pub fn initCfgu() -> Result;
- pub fn exitCfgu() -> Result;
+ pub fn cfguInit() -> Result;
+ pub fn cfguExit();
pub fn CFGU_SecureInfoGetRegion(region: *mut u8) -> Result;
- pub fn CFGU_GenHashConsoleUnique(appIDSalt: u32, hash: *mut u64) -> Result;
+ pub fn CFGU_GenHashConsoleUnique(appIDSalt: u32, hash: *mut u64)
+ -> Result;
pub fn CFGU_GetRegionCanadaUSA(value: *mut u8) -> Result;
pub fn CFGU_GetSystemModel(model: *mut u8) -> Result;
pub fn CFGU_GetModelNintendo2DS(value: *mut u8) -> Result;
pub fn CFGU_GetCountryCodeString(code: u16, string: *mut u16) -> Result;
pub fn CFGU_GetCountryCodeID(string: u16, code: *mut u16) -> Result;
- pub fn CFGU_GetConfigInfoBlk2(size: u32, blkID: u32, outData: *mut u8) -> Result;
+ pub fn CFGU_GetConfigInfoBlk2(size: u32, blkID: u32, outData: *mut u8)
+ -> Result;
pub fn CFGU_GetSystemLanguage(language: *mut u8) -> Result;
}
diff --git a/ctru-sys/src/services/dsp.rs b/ctru-sys/src/services/dsp.rs
new file mode 100644
index 0000000..12edfae
--- /dev/null
+++ b/ctru-sys/src/services/dsp.rs
@@ -0,0 +1,48 @@
+use ::{Handle, Result};
+use ::c_void;
+
+#[repr(C)]
+#[derive(Clone, Copy)]
+pub enum DSP_InterruptType {
+ DSP_INTERRUPT_PIPE = 2,
+}
+
+#[repr(C)]
+#[derive(Clone, Copy)]
+pub enum DSP_PipeDirection {
+ DSP_PIPE_INPUT = 0,
+ DSP_PIPE_OUTPUT = 1,
+}
+
+extern "C" {
+ pub fn dspInit() -> Result;
+ pub fn dspExit();
+ pub fn DSP_GetHeadphoneStatus(is_inserted: *mut u8) -> Result;
+ pub fn DSP_FlushDataCache(address: *const c_void,
+ size: u32) -> Result;
+ pub fn DSP_InvalidateDataCache(address: *const c_void,
+ size: u32) -> Result;
+ pub fn DSP_GetSemaphoreHandle(semaphore: *mut Handle) -> Result;
+ pub fn DSP_SetSemaphore(value: u16) -> Result;
+ pub fn DSP_SetSemaphoreMask(mask: u16) -> Result;
+ pub fn DSP_LoadComponent(component: *const c_void,
+ size: u32, prog_mask: u16, data_mask: u16,
+ is_loaded: *mut u8) -> Result;
+ pub fn DSP_UnloadComponent() -> Result;
+ pub fn DSP_RegisterInterruptEvents(handle: Handle, interrupt: u32,
+ channel: u32) -> Result;
+ pub fn DSP_ReadPipeIfPossible(channel: u32, peer: u32,
+ buffer: *mut c_void,
+ length: u16, length_read: *mut u16)
+ -> Result;
+ pub fn DSP_WriteProcessPipe(channel: u32,
+ buffer: *const c_void,
+ length: u32) -> Result;
+ pub fn DSP_ConvertProcessAddressFromDspDram(dsp_address: u32,
+ arm_address: *mut u32)
+ -> Result;
+ pub fn DSP_RecvData(regNo: u16, value: *mut u16) -> Result;
+ pub fn DSP_RecvDataIsReady(regNo: u16, is_ready: *mut u8) -> Result;
+ pub fn DSP_SendData(regNo: u16, value: u16) -> Result;
+ pub fn DSP_SendDataIsEmpty(regNo: u16, is_empty: *mut u8) -> Result;
+}
diff --git a/ctru-sys/src/services/fs.rs b/ctru-sys/src/services/fs.rs
new file mode 100644
index 0000000..4cd767c
--- /dev/null
+++ b/ctru-sys/src/services/fs.rs
@@ -0,0 +1,536 @@
+// TODO: Determine if anonymous enums are properly represented (they probably aren't)
+
+use ::{Handle, Result};
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed1 {
+ FS_OPEN_READ = 1,
+ FS_OPEN_WRITE = 2,
+ FS_OPEN_CREATE = 4,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed2 {
+ FS_WRITE_FLUSH = 1,
+ FS_WRITE_UPDATE_TIME = 256,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed3 {
+ FS_ATTRIBUTE_DIRECTORY = 1,
+ FS_ATTRIBUTE_HIDDEN = 256,
+ FS_ATTRIBUTE_ARCHIVE = 65536,
+ FS_ATTRIBUTE_READ_ONLY = 16777216,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed4 {
+ MEDIATYPE_NAND = 0,
+ MEDIATYPE_SD = 1,
+ MEDIATYPE_GAME_CARD = 2,
+}
+
+pub type FS_MediaType = Enum_Unnamed4;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed5 {
+ ARCHIVE_ROMFS = 3,
+ ARCHIVE_SAVEDATA = 4,
+ ARCHIVE_EXTDATA = 6,
+ ARCHIVE_SHARED_EXTDATA = 7,
+ ARCHIVE_SYSTEM_SAVEDATA = 8,
+ ARCHIVE_SDMC = 9,
+ ARCHIVE_SDMC_WRITE_ONLY = 10,
+ ARCHIVE_BOSS_EXTDATA = 305419896,
+ ARCHIVE_CARD_SPIFS = 305419897,
+ ARCHIVE_EXTDATA_AND_BOSS_EXTDATA = 305419899,
+ ARCHIVE_SYSTEM_SAVEDATA2 = 305419900,
+ ARCHIVE_NAND_RW = 305419901,
+ ARCHIVE_NAND_RO = 305419902,
+ ARCHIVE_NAND_RO_WRITE_ACCESS = 305419903,
+ ARCHIVE_SAVEDATA_AND_CONTENT = 591751050,
+ ARCHIVE_SAVEDATA_AND_CONTENT2 = 591751054,
+ ARCHIVE_NAND_CTR_FS = 1450741931,
+ ARCHIVE_TWL_PHOTO = 1450741932,
+ ARCHIVE_NAND_TWL_FS = 1450741934,
+ ARCHIVE_NAND_W_FS = 1450741935,
+ ARCHIVE_GAMECARD_SAVEDATA = 1450741937,
+ ARCHIVE_USER_SAVEDATA = 1450741938,
+ ARCHIVE_DEMO_SAVEDATA = 1450741940,
+}
+pub type FS_ArchiveID = Enum_Unnamed5;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed6 {
+ PATH_INVALID = 0,
+ PATH_EMPTY = 1,
+ PATH_BINARY = 2,
+ PATH_ASCII = 3,
+ PATH_UTF16 = 4,
+}
+pub type FS_PathType = Enum_Unnamed6;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed7 { SECUREVALUE_SLOT_SD = 4096, }
+pub type FS_SecureValueSlot = Enum_Unnamed7;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed8 {
+ BAUDRATE_512KHZ = 0,
+ BAUDRATE_1MHZ = 1,
+ BAUDRATE_2MHZ = 2,
+ BAUDRATE_4MHZ = 3,
+ BAUDRATE_8MHZ = 4,
+ BAUDRATE_16MHZ = 5,
+}
+pub type FS_CardSpiBaudRate = Enum_Unnamed8;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed9 {
+ BUSMODE_1BIT = 0,
+ BUSMODE_4BIT = 1,
+}
+pub type FS_CardSpiBusMode = Enum_Unnamed9;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed10 {
+ SPECIALCONTENT_UPDATE = 1,
+ SPECIALCONTENT_MANUAL = 2,
+ SPECIALCONTENT_DLP_CHILD = 3,
+}
+pub type FS_SpecialContentType = Enum_Unnamed10;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed11 { CARD_CTR = 0, CARD_TWL = 1, }
+pub type FS_CardType = Enum_Unnamed11;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed12 { FS_ACTION_UNKNOWN = 0, }
+pub type FS_Action = Enum_Unnamed12;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed13 {
+ ARCHIVE_ACTION_COMMIT_SAVE_DATA = 0,
+ ARCHIVE_ACTION_GET_TIMESTAMP = 1,
+}
+pub type FS_ArchiveAction = Enum_Unnamed13;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed14 {
+ SECURESAVE_ACTION_DELETE = 0,
+ SECURESAVE_ACTION_FORMAT = 1,
+}
+pub type FS_SecureSaveAction = Enum_Unnamed14;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed15 { FILE_ACTION_UNKNOWN = 0, }
+pub type FS_FileAction = Enum_Unnamed15;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed16 { DIRECTORY_ACTION_UNKNOWN = 0, }
+pub type FS_DirectoryAction = Enum_Unnamed16;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed17 {
+ pub name: [u16; 262usize],
+ pub shortName: [u8; 10usize],
+ pub shortExt: [u8; 4usize],
+ pub valid: u8,
+ pub reserved: u8,
+ pub attributes: u32,
+ pub fileSize: u64,
+}
+impl ::core::clone::Clone for Struct_Unnamed17 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed17 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type FS_DirectoryEntry = Struct_Unnamed17;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed18 {
+ pub sectorSize: u32,
+ pub clusterSize: u32,
+ pub totalClusters: u32,
+ pub freeClusters: u32,
+}
+impl ::core::clone::Clone for Struct_Unnamed18 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed18 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type FS_ArchiveResource = Struct_Unnamed18;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed19 {
+ pub programId: u64,
+ pub _bindgen_bitfield_1_: FS_MediaType,
+ pub padding: [u8; 7usize],
+}
+impl ::core::clone::Clone for Struct_Unnamed19 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed19 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type FS_ProgramInfo = Struct_Unnamed19;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed20 {
+ pub productCode: [u8; 16usize],
+ pub companyCode: [u8; 2usize],
+ pub remasterVersion: u16,
+}
+impl ::core::clone::Clone for Struct_Unnamed20 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed20 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type FS_ProductInfo = Struct_Unnamed20;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed21 {
+ pub aesCbcMac: [u8; 16usize],
+ pub movableSed: [u8; 288usize],
+}
+impl ::core::clone::Clone for Struct_Unnamed21 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed21 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type FS_IntegrityVerificationSeed = Struct_Unnamed21;
+
+#[repr(C, packed)]
+#[derive(Copy)]
+pub struct Struct_Unnamed22 {
+ pub _bindgen_bitfield_1_: FS_MediaType,
+ pub unknown: u8,
+ pub reserved1: u16,
+ pub saveId: u64,
+ pub reserved2: u32,
+}
+impl ::core::clone::Clone for Struct_Unnamed22 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed22 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type FS_ExtSaveDataInfo = Struct_Unnamed22;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed23 {
+ pub _bindgen_bitfield_1_: FS_MediaType,
+ pub unknown: u8,
+ pub reserved: u16,
+ pub saveId: u32,
+}
+impl ::core::clone::Clone for Struct_Unnamed23 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed23 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type FS_SystemSaveDataInfo = Struct_Unnamed23;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed24 {
+ pub ivs: [u8; 16usize],
+ pub encryptParameter: [u8; 16usize],
+}
+impl ::core::clone::Clone for Struct_Unnamed24 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed24 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type FS_DeviceMoveContext = Struct_Unnamed24;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed25 {
+ pub _type: FS_PathType,
+ pub size: u32,
+ pub data: *const ::c_void,
+}
+impl ::core::clone::Clone for Struct_Unnamed25 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed25 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type FS_Path = Struct_Unnamed25;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed26 {
+ pub id: u32,
+ pub lowPath: FS_Path,
+ pub handle: u64,
+}
+impl ::core::clone::Clone for Struct_Unnamed26 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed26 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type FS_Archive = Struct_Unnamed26;
+extern "C" {
+ pub fn fsInit() -> Result;
+ pub fn fsExit();
+ pub fn fsUseSession(session: Handle, sdmc: u8);
+ pub fn fsEndUseSession();
+ pub fn fsMakePath(_type: FS_PathType, path: *const ::c_void)
+ -> FS_Path;
+ pub fn fsGetSessionHandle() -> *mut Handle;
+ pub fn FSUSER_Control(action: FS_Action,
+ input: *mut ::c_void, inputSize: u32,
+ output: *mut ::c_void,
+ outputSize: u32) -> Result;
+ pub fn FSUSER_Initialize(session: Handle) -> Result;
+ pub fn FSUSER_OpenFile(out: *mut Handle, archive: FS_Archive,
+ path: FS_Path, openFlags: u32, attributes: u32)
+ -> Result;
+ pub fn FSUSER_OpenFileDirectly(out: *mut Handle, archive: FS_Archive,
+ path: FS_Path, openFlags: u32,
+ attributes: u32) -> Result;
+ pub fn FSUSER_DeleteFile(archive: FS_Archive, path: FS_Path) -> Result;
+ pub fn FSUSER_RenameFile(srcArchive: FS_Archive, srcPath: FS_Path,
+ dstArchive: FS_Archive, dstPath: FS_Path)
+ -> Result;
+ pub fn FSUSER_DeleteDirectory(archive: FS_Archive, path: FS_Path)
+ -> Result;
+ pub fn FSUSER_DeleteDirectoryRecursively(archive: FS_Archive,
+ path: FS_Path) -> Result;
+ pub fn FSUSER_CreateFile(archive: FS_Archive, path: FS_Path,
+ attributes: u32, fileSize: u64) -> Result;
+ pub fn FSUSER_CreateDirectory(archive: FS_Archive, path: FS_Path,
+ attributes: u32) -> Result;
+ pub fn FSUSER_RenameDirectory(srcArchive: FS_Archive, srcPath: FS_Path,
+ dstArchive: FS_Archive, dstPath: FS_Path)
+ -> Result;
+ pub fn FSUSER_OpenDirectory(out: *mut Handle, archive: FS_Archive,
+ path: FS_Path) -> Result;
+ pub fn FSUSER_OpenArchive(archive: *mut FS_Archive) -> Result;
+ pub fn FSUSER_ControlArchive(archive: FS_Archive,
+ action: FS_ArchiveAction,
+ input: *mut ::c_void,
+ inputSize: u32,
+ output: *mut ::c_void,
+ outputSize: u32) -> Result;
+ pub fn FSUSER_CloseArchive(archive: *mut FS_Archive) -> Result;
+ pub fn FSUSER_GetFreeBytes(freeBytes: *mut u64, archive: FS_Archive)
+ -> Result;
+ pub fn FSUSER_GetCardType(_type: *mut FS_CardType) -> Result;
+ pub fn FSUSER_GetSdmcArchiveResource(archiveResource:
+ *mut FS_ArchiveResource)
+ -> Result;
+ pub fn FSUSER_GetNandArchiveResource(archiveResource:
+ *mut FS_ArchiveResource)
+ -> Result;
+ pub fn FSUSER_GetSdmcFatfsError(error: *mut u32) -> Result;
+ pub fn FSUSER_IsSdmcDetected(detected: *mut u8) -> Result;
+ pub fn FSUSER_IsSdmcWritable(writable: *mut u8) -> Result;
+ pub fn FSUSER_GetSdmcCid(out: *mut u8, length: u32) -> Result;
+ pub fn FSUSER_GetNandCid(out: *mut u8, length: u32) -> Result;
+ pub fn FSUSER_GetSdmcSpeedInfo(speedInfo: *mut u32) -> Result;
+ pub fn FSUSER_GetNandSpeedInfo(speedInfo: *mut u32) -> Result;
+ pub fn FSUSER_GetSdmcLog(out: *mut u8, length: u32) -> Result;
+ pub fn FSUSER_GetNandLog(out: *mut u8, length: u32) -> Result;
+ pub fn FSUSER_ClearSdmcLog() -> Result;
+ pub fn FSUSER_ClearNandLog() -> Result;
+ pub fn FSUSER_CardSlotIsInserted(inserted: *mut u8) -> Result;
+ pub fn FSUSER_CardSlotPowerOn(status: *mut u8) -> Result;
+ pub fn FSUSER_CardSlotPowerOff(status: *mut u8) -> Result;
+ pub fn FSUSER_CardSlotGetCardIFPowerStatus(status: *mut u8) -> Result;
+ pub fn FSUSER_CardNorDirectCommand(commandId: u8) -> Result;
+ pub fn FSUSER_CardNorDirectCommandWithAddress(commandId: u8,
+ address: u32) -> Result;
+ pub fn FSUSER_CardNorDirectRead(commandId: u8, size: u32,
+ output: *mut u8) -> Result;
+ pub fn FSUSER_CardNorDirectReadWithAddress(commandId: u8, address: u32,
+ size: u32, output: *mut u8)
+ -> Result;
+ pub fn FSUSER_CardNorDirectWrite(commandId: u8, size: u32,
+ input: *mut u8) -> Result;
+ pub fn FSUSER_CardNorDirectWriteWithAddress(commandId: u8, address: u32,
+ size: u32, input: *mut u8)
+ -> Result;
+ pub fn FSUSER_CardNorDirectRead_4xIO(commandId: u8, address: u32,
+ size: u32, output: *mut u8)
+ -> Result;
+ pub fn FSUSER_CardNorDirectCpuWriteWithoutVerify(address: u32,
+ size: u32,
+ input: *mut u8)
+ -> Result;
+ pub fn FSUSER_CardNorDirectSectorEraseWithoutVerify(address: u32)
+ -> Result;
+ pub fn FSUSER_GetProductInfo(info: *mut FS_ProductInfo, processId: u32)
+ -> Result;
+ pub fn FSUSER_GetProgramLaunchInfo(info: *mut FS_ProgramInfo,
+ processId: u32) -> Result;
+ pub fn FSUSER_SetCardSpiBaudRate(baudRate: FS_CardSpiBaudRate) -> Result;
+ pub fn FSUSER_SetCardSpiBusMode(busMode: FS_CardSpiBusMode) -> Result;
+ pub fn FSUSER_SendInitializeInfoTo9() -> Result;
+ pub fn FSUSER_GetSpecialContentIndex(index: *mut u16,
+ mediaType: FS_MediaType,
+ programId: u64,
+ _type: FS_SpecialContentType)
+ -> Result;
+ pub fn FSUSER_GetLegacyRomHeader(mediaType: FS_MediaType, programId: u64,
+ header: *mut u8) -> Result;
+ pub fn FSUSER_GetLegacyBannerData(mediaType: FS_MediaType, programId: u64,
+ banner: *mut u8) -> Result;
+ pub fn FSUSER_CheckAuthorityToAccessExtSaveData(access: *mut u8,
+ mediaType: FS_MediaType,
+ saveId: u64,
+ processId: u32)
+ -> Result;
+ pub fn FSUSER_QueryTotalQuotaSize(quotaSize: *mut u64, directories: u32,
+ files: u32, fileSizeCount: u32,
+ fileSizes: *mut u64) -> Result;
+ pub fn FSUSER_AbnegateAccessRight(accessRight: u32) -> Result;
+ pub fn FSUSER_DeleteSdmcRoot() -> Result;
+ pub fn FSUSER_DeleteAllExtSaveDataOnNand() -> Result;
+ pub fn FSUSER_InitializeCtrFileSystem() -> Result;
+ pub fn FSUSER_CreateSeed() -> Result;
+ pub fn FSUSER_GetFormatInfo(totalSize: *mut u32, directories: *mut u32,
+ files: *mut u32, duplicateData: *mut u8,
+ archiveId: FS_ArchiveID, path: FS_Path)
+ -> Result;
+ pub fn FSUSER_GetLegacyRomHeader2(headerSize: u32,
+ mediaType: FS_MediaType, programId: u64,
+ header: *mut u8) -> Result;
+ pub fn FSUSER_GetSdmcCtrRootPath(out: *mut u8, length: u32) -> Result;
+ pub fn FSUSER_GetArchiveResource(archiveResource: *mut FS_ArchiveResource,
+ mediaType: FS_MediaType) -> Result;
+ pub fn FSUSER_ExportIntegrityVerificationSeed(seed:
+ *mut FS_IntegrityVerificationSeed)
+ -> Result;
+ pub fn FSUSER_ImportIntegrityVerificationSeed(seed:
+ *mut FS_IntegrityVerificationSeed)
+ -> Result;
+ pub fn FSUSER_FormatSaveData(archiveId: FS_ArchiveID, path: FS_Path,
+ blocks: u32, directories: u32, files: u32,
+ directoryBuckets: u32, fileBuckets: u32,
+ duplicateData: u8) -> Result;
+ pub fn FSUSER_GetLegacySubBannerData(bannerSize: u32,
+ mediaType: FS_MediaType,
+ programId: u64, banner: *mut u8)
+ -> Result;
+ pub fn FSUSER_ReadSpecialFile(bytesRead: *mut u32, fileOffset: u64,
+ size: u32, data: *mut u8) -> Result;
+ pub fn FSUSER_GetSpecialFileSize(fileSize: *mut u64) -> Result;
+ pub fn FSUSER_CreateExtSaveData(info: FS_ExtSaveDataInfo,
+ directories: u32, files: u32,
+ sizeLimit: u64, smdhSize: u32,
+ smdh: *mut u8) -> Result;
+ pub fn FSUSER_DeleteExtSaveData(info: FS_ExtSaveDataInfo) -> Result;
+ pub fn FSUSER_ReadExtSaveDataIcon(bytesRead: *mut u32,
+ info: FS_ExtSaveDataInfo,
+ smdhSize: u32, smdh: *mut u8)
+ -> Result;
+ pub fn FSUSER_GetExtDataBlockSize(totalBlocks: *mut u64,
+ freeBlocks: *mut u64,
+ blockSize: *mut u32,
+ info: FS_ExtSaveDataInfo) -> Result;
+ pub fn FSUSER_EnumerateExtSaveData(idsWritten: *mut u32, idsSize: u32,
+ mediaType: FS_MediaType, idSize: u32,
+ shared: u8, ids: *mut u8) -> Result;
+ pub fn FSUSER_CreateSystemSaveData(info: FS_SystemSaveDataInfo,
+ totalSize: u32, blockSize: u32,
+ directories: u32, files: u32,
+ directoryBuckets: u32,
+ fileBuckets: u32, duplicateData: u8)
+ -> Result;
+ pub fn FSUSER_DeleteSystemSaveData(info: FS_SystemSaveDataInfo) -> Result;
+ pub fn FSUSER_StartDeviceMoveAsSource(context: *mut FS_DeviceMoveContext)
+ -> Result;
+ pub fn FSUSER_StartDeviceMoveAsDestination(context: FS_DeviceMoveContext,
+ clear: u8) -> Result;
+ pub fn FSUSER_SetArchivePriority(archive: FS_Archive, priority: u32)
+ -> Result;
+ pub fn FSUSER_GetArchivePriority(priority: *mut u32, archive: FS_Archive)
+ -> Result;
+ pub fn FSUSER_SetCtrCardLatencyParameter(latency: u64,
+ emulateEndurance: u8) -> Result;
+ pub fn FSUSER_SwitchCleanupInvalidSaveData(enable: u8) -> Result;
+ pub fn FSUSER_EnumerateSystemSaveData(idsWritten: *mut u32,
+ idsSize: u32, ids: *mut u64)
+ -> Result;
+ pub fn FSUSER_InitializeWithSdkVersion(session: Handle, version: u32)
+ -> Result;
+ pub fn FSUSER_SetPriority(priority: u32) -> Result;
+ pub fn FSUSER_GetPriority(priority: *mut u32) -> Result;
+ pub fn FSUSER_SetSaveDataSecureValue(value: u64, slot: FS_SecureValueSlot,
+ titleUniqueId: u32,
+ titleVariation: u8) -> Result;
+ pub fn FSUSER_GetSaveDataSecureValue(exists: *mut u8, value: *mut u64,
+ slot: FS_SecureValueSlot,
+ titleUniqueId: u32,
+ titleVariation: u8) -> Result;
+ pub fn FSUSER_ControlSecureSave(action: FS_SecureSaveAction,
+ input: *mut ::c_void,
+ inputSize: u32,
+ output: *mut ::c_void,
+ outputSize: u32) -> Result;
+ pub fn FSUSER_GetMediaType(mediaType: *mut FS_MediaType) -> Result;
+ pub fn FSFILE_Control(handle: Handle, action: FS_FileAction,
+ input: *mut ::c_void, inputSize: u32,
+ output: *mut ::c_void,
+ outputSize: u32) -> Result;
+ pub fn FSFILE_OpenSubFile(handle: Handle, subFile: *mut Handle,
+ offset: u64, size: u64) -> Result;
+ pub fn FSFILE_Read(handle: Handle, bytesRead: *mut u32, offset: u64,
+ buffer: *mut ::c_void, size: u32)
+ -> Result;
+ pub fn FSFILE_Write(handle: Handle, bytesWritten: *mut u32, offset: u64,
+ buffer: *const ::c_void, size: u32,
+ flags: u32) -> Result;
+ pub fn FSFILE_GetSize(handle: Handle, size: *mut u64) -> Result;
+ pub fn FSFILE_SetSize(handle: Handle, size: u64) -> Result;
+ pub fn FSFILE_GetAttributes(handle: Handle, attributes: *mut u32)
+ -> Result;
+ pub fn FSFILE_SetAttributes(handle: Handle, attributes: u32) -> Result;
+ pub fn FSFILE_Close(handle: Handle) -> Result;
+ pub fn FSFILE_Flush(handle: Handle) -> Result;
+ pub fn FSFILE_SetPriority(handle: Handle, priority: u32) -> Result;
+ pub fn FSFILE_GetPriority(handle: Handle, priority: *mut u32) -> Result;
+ pub fn FSFILE_OpenLinkFile(handle: Handle, linkFile: *mut Handle)
+ -> Result;
+ pub fn FSDIR_Control(handle: Handle, action: FS_DirectoryAction,
+ input: *mut ::c_void, inputSize: u32,
+ output: *mut ::c_void,
+ outputSize: u32) -> Result;
+ pub fn FSDIR_Read(handle: Handle, entriesRead: *mut u32,
+ entryCount: u32, entries: *mut FS_DirectoryEntry)
+ -> Result;
+ pub fn FSDIR_Close(handle: Handle) -> Result;
+ pub fn FSDIR_SetPriority(handle: Handle, priority: u32) -> Result;
+ pub fn FSDIR_GetPriority(handle: Handle, priority: *mut u32) -> Result;
+}
diff --git a/ctru-sys/src/services/gsp.rs b/ctru-sys/src/services/gsp.rs
deleted file mode 100644
index 9f8cf20..0000000
--- a/ctru-sys/src/services/gsp.rs
+++ /dev/null
@@ -1,83 +0,0 @@
-use super::super::types::*;
-
-#[inline]
-pub fn GSP_REBASE_REG(r: u32) {
- ((r)-0x1EB00000);
-}
-
-#[repr(C)]
-#[derive(Clone, Copy)]
-pub struct GSP_FramebufferInfo {
- active_framebuf: u32, //"0=first, 1=second"
- framebuf0_vaddr: *mut u32, //"Framebuffer virtual address, for the main screen this is the 3D left framebuffer"
- framebuf1_vaddr: *mut u32,//"For the main screen: 3D right framebuffer address"
- framebuf_widthbytesize: u32, //"Value for 0x1EF00X90, controls framebuffer width"
- format: u32,//"Framebuffer format, this u16 is written to the low u16 for LCD register 0x1EF00X70."
- framebuf_dispselect: u32, //"Value for 0x1EF00X78, controls which framebuffer is displayed"
- unk: u32 //"?"
-}
-
-#[repr(C)]
-#[derive(Clone, Copy)]
-pub enum GSP_FramebufferFormats {
- GSP_RGBA8_OES=0, //pixel_size = 4-bytes
- GSP_BGR8_OES=1, //pixel_size = 3-bytes
- GSP_RGB565_OES=2, //pixel_size = 2-bytes
- GSP_RGB5_A1_OES=3, //pixel_size = 2-bytes
- GSP_RGBA4_OES=4 //pixel_size = 2-bytes
-}
-
-#[repr(C)]
-#[derive(Clone, Copy)]
-pub struct GSP_CaptureInfoEntry { //See this for GSP_CaptureInfoEntry and GSP_CaptureInfo: http://3dbrew.org/wiki/GSPGPU:ImportDisplayCaptureInfo
- framebuf0_vaddr: *mut u32,
- framebuf1_vaddr: *mut u32,
- format: u32,
- framebuf_widthbytesize: u32,
-}
-
-#[repr(C)]
-#[derive(Clone, Copy)]
-pub struct GSP_CaptureInfo {
- screencapture: [GSP_CaptureInfoEntry; 2usize]
-}
-
-#[repr(C)]
-pub enum GSP_Event {
- GSPEVENT_PSC0 = 0, // memory fill completed
- GSPEVENT_PSC1,
- GSPEVENT_VBlank0,
- GSPEVENT_VBlank1,
- GSPEVENT_PPF, // display transfer finished
- GSPEVENT_P3D, // command list processing finished
- GSPEVENT_DMA,
-
- GSPEVENT_MAX, // used to know how many events there are
-}
-
-use super::super::{Result, Handle};
-
-
-extern "C" {
- pub fn gspInit() -> Result;
- pub fn gspExit() -> ();
- pub fn gspInitEventHandler(gspEvent: Handle, gspSharedMem: *mut vu8, gspThreadId: u8) -> Result;
- pub fn gspExitEventHandler() -> ();
- pub fn gspWaitForEvent(id: GSP_Event, nextEvent: u8) -> ();
- pub fn GSPGPU_AcquireRight(handle: *mut Handle, flags: u8) -> Result;
- pub fn GSPGPU_ReleaseRight(handle: *mut Handle) -> Result;
- pub fn GSPGPU_ImportDisplayCaptureInfo(handle: *mut Handle, captureinfo: *mut GSP_CaptureInfo) -> Result;
- pub fn GSPGPU_SaveVramSysArea(handle: *mut Handle) -> Result;
- pub fn GSPGPU_RestoreVramSysArea(handle: *mut Handle) -> Result;
- pub fn GSPGPU_SetLcdForceBlack(handle: *mut Handle, flags: u8) -> Result;
- pub fn GSPGPU_SetBufferSwap(handle: *mut Handle, screenid: u32, framebufinfo: *mut GSP_FramebufferInfo) -> Result;
- pub fn GSPGPU_FlushDataCache(handle: *mut Handle, adr: *mut u8, size: u32) -> Result;
- pub fn GSPGPU_InvalidateDataCache(handle: *mut Handle, adr: *mut u8, size: u32) -> Result;
- pub fn GSPGPU_WriteHWRegs(handle: *mut Handle, regAddr: u32, data: *mut u32, size: u8) -> Result;
- pub fn GSPGPU_WriteHWRegsWithMask(handle: *mut Handle, regAddr: u32, data: *mut u32, datasize: u8, maskdata: *mut u32, masksize: u8) -> Result;
- pub fn GSPGPU_ReadHWRegs(handle: *mut Handle, regAddr: u32, data: *mut u32, size: u8) -> Result;
- pub fn GSPGPU_RegisterInterruptRelayQueue(handle: *mut Handle, eventHandle: Handle, flags: u32, outMemHandle: *mut Handle, threadID: *mut u8) -> Result;
- pub fn GSPGPU_UnregisterInterruptRelayQueue(handle: *mut Handle) -> Result;
- pub fn GSPGPU_TriggerCmdReqQueue(handle: *mut Handle) -> Result;
- pub fn GSPGPU_SubmitGxCommand(sharedGspCmdBuf: *mut u32, gxCommand: *mut u32, handle: *mut Handle) -> Result;
-}
diff --git a/ctru-sys/src/services/gspgpu.rs b/ctru-sys/src/services/gspgpu.rs
new file mode 100644
index 0000000..7265812
--- /dev/null
+++ b/ctru-sys/src/services/gspgpu.rs
@@ -0,0 +1,120 @@
+use ::{Handle, Result};
+use ::c_void;
+use ::types::*;
+
+#[inline]
+pub fn GSPGPU_REBASE_REG(r: u32) {
+ ((r)-0x1EB00000);
+}
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct GSPGPU_FramebufferInfo {
+ pub active_framebuf: u32,
+ pub framebuf0_vaddr: *mut u32,
+ pub framebuf1_vaddr: *mut u32,
+ pub framebuf_widthbytesize: u32,
+ pub format: u32,
+ pub framebuf_dispselect: u32,
+ pub unk: u32,
+}
+impl ::core::clone::Clone for GSPGPU_FramebufferInfo {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for GSPGPU_FramebufferInfo {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum GSPGPU_FramebufferFormats {
+ GSP_RGBA8_OES = 0,
+ GSP_BGR8_OES = 1,
+ GSP_RGB565_OES = 2,
+ GSP_RGB5_A1_OES = 3,
+ GSP_RGBA4_OES = 4,
+}
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct GSPGPU_CaptureInfoEntry {
+ pub framebuf0_vaddr: *mut u32,
+ pub framebuf1_vaddr: *mut u32,
+ pub format: u32,
+ pub framebuf_widthbytesize: u32,
+}
+impl ::core::clone::Clone for GSPGPU_CaptureInfoEntry {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for GSPGPU_CaptureInfoEntry {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct GSPGPU_CaptureInfo {
+ pub screencapture: [GSPGPU_CaptureInfoEntry; 2usize],
+}
+impl ::core::clone::Clone for GSPGPU_CaptureInfo {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for GSPGPU_CaptureInfo {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+
+#[repr(C)]
+pub enum GSPGPU_Event {
+ GSPGPU_EVENT_PSC0 = 0,
+ GSPGPU_EVENT_PSC1 = 1,
+ GSPGPU_EVENT_VBlank0 = 2,
+ GSPGPU_EVENT_VBlank1 = 3,
+ GSPGPU_EVENT_PPF = 4,
+ GSPGPU_EVENT_P3D = 5,
+ GSPGPU_EVENT_DMA = 6,
+ GSPGPU_EVENT_MAX = 7,
+}
+
+use ThreadFunc;
+
+extern "C" {
+ pub fn gspInit() -> Result;
+ pub fn gspExit();
+ pub fn gspSetEventCallback(id: GSPGPU_Event, cb: ThreadFunc,
+ data: *mut c_void,
+ oneShot: u8);
+ pub fn gspInitEventHandler(gspEvent: Handle, gspSharedMem: *mut vu8,
+ gspThreadId: u8) -> Result;
+ pub fn gspExitEventHandler();
+ pub fn gspWaitForEvent(id: GSPGPU_Event, nextEvent: u8);
+ pub fn gspWaitForAnyEvent() -> GSPGPU_Event;
+ pub fn gspSubmitGxCommand(sharedGspCmdBuf: *mut u32,
+ gxCommand: *mut u32) -> Result;
+ pub fn GSPGPU_AcquireRight(flags: u8) -> Result;
+ pub fn GSPGPU_ReleaseRight() -> Result;
+ pub fn GSPGPU_ImportDisplayCaptureInfo(captureinfo:
+ *mut GSPGPU_CaptureInfo)
+ -> Result;
+ pub fn GSPGPU_SaveVramSysArea() -> Result;
+ pub fn GSPGPU_RestoreVramSysArea() -> Result;
+ pub fn GSPGPU_SetLcdForceBlack(flags: u8) -> Result;
+ pub fn GSPGPU_SetBufferSwap(screenid: u32,
+ framebufinfo: *mut GSPGPU_FramebufferInfo)
+ -> Result;
+ pub fn GSPGPU_FlushDataCache(adr: *const c_void,
+ size: u32) -> Result;
+ pub fn GSPGPU_InvalidateDataCache(adr: *const c_void,
+ size: u32) -> Result;
+ pub fn GSPGPU_WriteHWRegs(regAddr: u32, data: *mut u32, size: u8)
+ -> Result;
+ pub fn GSPGPU_WriteHWRegsWithMask(regAddr: u32, data: *mut u32,
+ datasize: u8, maskdata: *mut u32,
+ masksize: u8) -> Result;
+ pub fn GSPGPU_ReadHWRegs(regAddr: u32, data: *mut u32, size: u8)
+ -> Result;
+ pub fn GSPGPU_RegisterInterruptRelayQueue(eventHandle: Handle,
+ flags: u32,
+ outMemHandle: *mut Handle,
+ threadID: *mut u8) -> Result;
+ pub fn GSPGPU_UnregisterInterruptRelayQueue() -> Result;
+ pub fn GSPGPU_TriggerCmdReqQueue() -> Result;
+}
diff --git a/ctru-sys/src/services/gsplcd.rs b/ctru-sys/src/services/gsplcd.rs
new file mode 100644
index 0000000..332ebef
--- /dev/null
+++ b/ctru-sys/src/services/gsplcd.rs
@@ -0,0 +1,17 @@
+//TODO: Verify if anonymous enum is properly represented
+
+use ::Result;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed1 {
+ GSPLCD_SCREEN_TOP = 1,
+ GSPLCD_SCREEN_BOTTOM = 2,
+ GSPLCD_SCREEN_BOTH = 3,
+}
+extern "C" {
+ pub fn gspLcdInit() -> Result;
+ pub fn gspLcdExit();
+ pub fn GSPLCD_PowerOnBacklight(screen: u32) -> Result;
+ pub fn GSPLCD_PowerOffBacklight(screen: u32) -> Result;
+}
diff --git a/ctru-sys/src/services/hb.rs b/ctru-sys/src/services/hb.rs
index 6cd2128..7bfe5fb 100644
--- a/ctru-sys/src/services/hb.rs
+++ b/ctru-sys/src/services/hb.rs
@@ -6,6 +6,8 @@ extern "C" {
pub fn hbInit() -> Result;
pub fn hbExit() -> ();
pub fn HB_FlushInvalidateCache() -> Result;
- pub fn HB_GetBootloaderAddresses(load3dsx: *mut *mut c_void, setArgv: *mut *mut c_void) -> Result;
- pub fn HB_ReprotectMemory(addr: *mut u32, pages: u32, mode: u32, reprotectedPages: *mut u32) -> Result;
+ pub fn HB_GetBootloaderAddresses(load3dsx: *mut *mut c_void, setArgv: *mut *mut c_void)
+ -> Result;
+ pub fn HB_ReprotectMemory(addr: *mut u32, pages: u32, mode: u32, reprotectedPages: *mut u32)
+ -> Result;
}
diff --git a/ctru-sys/src/services/hid.rs b/ctru-sys/src/services/hid.rs
index f48f26b..8e3a025 100644
--- a/ctru-sys/src/services/hid.rs
+++ b/ctru-sys/src/services/hid.rs
@@ -5,35 +5,39 @@ pub const HID_SHAREDMEM_DEFAULT: u32 = 0x10000000;
#[repr(C)]
pub enum PAD_KEY {
- KEY_A = 1,
- KEY_B = 2,
- KEY_SELECT = 4,
- KEY_START = 8,
- KEY_DRIGHT = 16,
- KEY_DLEFT = 32,
- KEY_DUP = 64,
- KEY_DDOWN = 128,
- KEY_R = 256,
- KEY_L = 512,
- KEY_X = 1024,
- KEY_Y = 2048,
- KEY_ZL = 4096, // (new 3DS only)
- KEY_ZR = 8192, // (new 3DS only)
- KEY_TOUCH = 1048576, // Not actually provided by HID
- KEY_CSTICK_RIGHT = 16777216, // c-stick (new 3DS only)
- KEY_CSTICK_LEFT = 33554432, // c-stick (new 3DS only)
- KEY_CSTICK_UP = 67108864, // c-stick (new 3DS only)
- KEY_CSTICK_DOWN = 134217728, // c-stick (new 3DS only)
- KEY_CPAD_RIGHT = 268435456, // circle pad
- KEY_CPAD_LEFT = 536870912, // circle pad
- KEY_CPAD_UP = 1073741824, // circle pad
- KEY_CPAD_DOWN = 2147483648, // circle pad
+ KEY_A = 1,
+ KEY_B = 2,
+ KEY_SELECT = 4,
+ KEY_START = 8,
+ KEY_DRIGHT = 16,
+ KEY_DLEFT = 32,
+ KEY_DUP = 64,
+ KEY_DDOWN = 128,
+ KEY_R = 256,
+ KEY_L = 512,
+ KEY_X = 1024,
+ KEY_Y = 2048,
+ KEY_ZL = 16384,
+ KEY_ZR = 32768,
+ KEY_TOUCH = 1048576,
+ KEY_CSTICK_RIGHT = 16777216,
+ KEY_CSTICK_LEFT = 33554432,
+ KEY_CSTICK_UP = 67108864,
+ KEY_CSTICK_DOWN = 134217728,
+ KEY_CPAD_RIGHT = 268435456,
+ KEY_CPAD_LEFT = 536870912,
+ KEY_CPAD_UP = 1073741824,
+ KEY_CPAD_DOWN = -2147483648,
+ KEY_UP = 1073741888,
+ KEY_DOWN = -2147483520,
+ KEY_LEFT = 536870944,
+ KEY_RIGHT = 268435472,
- // Generic catch-all directions
- /*KEY_UP = KEY_DUP | KEY_CPAD_UP,
- KEY_DOWN = KEY_DDOWN | KEY_CPAD_DOWN,
- KEY_LEFT = KEY_DLEFT | KEY_CPAD_LEFT,
- KEY_RIGHT = KEY_DRIGHT | KEY_CPAD_RIGHT,*/
+ // Generic catch-all directions
+ /*KEY_UP = KEY_DUP | KEY_CPAD_UP,
+ KEY_DOWN = KEY_DDOWN | KEY_CPAD_DOWN,
+ KEY_LEFT = KEY_DLEFT | KEY_CPAD_LEFT,
+ KEY_RIGHT = KEY_DRIGHT | KEY_CPAD_RIGHT,*/
}
#[repr(C)]
@@ -68,36 +72,39 @@ pub struct angularRate {
#[repr(C)]
pub enum HID_Event {
- HIDEVENT_PAD0 = 0, //"Event signaled by HID-module, when the sharedmem+0(PAD/circle-pad)/+0xA8(touch-screen) region was updated."
- HIDEVENT_PAD1, //"Event signaled by HID-module, when the sharedmem+0(PAD/circle-pad)/+0xA8(touch-screen) region was updated."
- HIDEVENT_Accel, //"Event signaled by HID-module, when the sharedmem accelerometer state was updated."
- HIDEVENT_Gyro, //"Event signaled by HID-module, when the sharedmem gyroscope state was updated."
- HIDEVENT_DebugPad, //"Event signaled by HID-module, when the sharedmem DebugPad state was updated."
+ HIDEVENT_PAD0 = 0,
+ HIDEVENT_PAD1 = 1,
+ HIDEVENT_Accel = 2,
+ HIDEVENT_Gyro = 3,
+ HIDEVENT_DebugPad = 4,
+ HIDEVENT_MAX = 5,
- HIDEVENT_MAX, // used to know how many events there are
}
extern "C" {
- pub static hidMemHandle: Handle;
- pub static hidSharedMem: *mut vu32;
-
- pub fn hidInit(sharedMem: *mut u32) -> Result;
- pub fn hidExit() -> ();
- pub fn hidScanInput() -> ();
+ pub fn hidInit() -> Result;
+ pub fn hidExit();
+ pub fn hidScanInput();
pub fn hidKeysHeld() -> u32;
pub fn hidKeysDown() -> u32;
pub fn hidKeysUp() -> u32;
- pub fn hidTouchRead(pos: *mut touchPosition) -> ();
- pub fn hidCircleRead(pos: *mut circlePosition) -> ();
- pub fn hidAccelRead(vector: *mut accelVector) -> ();
- pub fn hidGyroRead(rate: *mut angularRate) -> ();
- pub fn hidWaitForEvent(id: HID_Event, nextEvent: u8) -> ();
- pub fn HIDUSER_GetHandles(outMemHandle: *mut Handle, eventpad0: *mut Handle, eventpad1: *mut Handle, eventaccel: *mut Handle, eventgyro: *mut Handle, eventdebugpad: *mut Handle) -> Result;
+ pub fn hidTouchRead(pos: *mut touchPosition);
+ pub fn hidCircleRead(pos: *mut circlePosition);
+ pub fn hidAccelRead(vector: *mut accelVector);
+ pub fn hidGyroRead(rate: *mut angularRate);
+ pub fn hidWaitForEvent(id: HID_Event, nextEvent: u8);
+ pub fn HIDUSER_GetHandles(outMemHandle: *mut Handle,
+ eventpad0: *mut Handle, eventpad1: *mut Handle,
+ eventaccel: *mut Handle, eventgyro: *mut Handle,
+ eventdebugpad: *mut Handle) -> Result;
pub fn HIDUSER_EnableAccelerometer() -> Result;
pub fn HIDUSER_DisableAccelerometer() -> Result;
pub fn HIDUSER_EnableGyroscope() -> Result;
pub fn HIDUSER_DisableGyroscope() -> Result;
- pub fn HIDUSER_GetGyroscopeRawToDpsCoefficient(coeff: *mut f32) -> Result;
+ pub fn HIDUSER_GetGyroscopeRawToDpsCoefficient(coeff:
+ *mut f32)
+ -> Result;
pub fn HIDUSER_GetSoundVolume(volume: *mut u8) -> Result;
}
+
diff --git a/ctru-sys/src/services/httpc.rs b/ctru-sys/src/services/httpc.rs
new file mode 100644
index 0000000..ba4eba4
--- /dev/null
+++ b/ctru-sys/src/services/httpc.rs
@@ -0,0 +1,79 @@
+use ::{Handle, Result};
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct httpcContext {
+ pub servhandle: Handle,
+ pub httphandle: u32,
+}
+impl ::core::clone::Clone for httpcContext {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for httpcContext {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum HTTPC_RequestStatus {
+ HTTPC_STATUS_REQUEST_IN_PROGRESS = 5,
+ HTTPC_STATUS_DOWNLOAD_READY = 7,
+}
+
+extern "C" {
+ pub fn httpcInit() -> Result;
+ pub fn httpcExit();
+ pub fn httpcOpenContext(context: *mut httpcContext,
+ url: *mut u8,
+ use_defaultproxy: u32) -> Result;
+ pub fn httpcCloseContext(context: *mut httpcContext) -> Result;
+ pub fn httpcAddRequestHeaderField(context: *mut httpcContext,
+ name: *mut u8,
+ value: *mut u8)
+ -> Result;
+ pub fn httpcBeginRequest(context: *mut httpcContext) -> Result;
+ pub fn httpcReceiveData(context: *mut httpcContext, buffer: *mut u8,
+ size: u32) -> Result;
+ pub fn httpcGetRequestState(context: *mut httpcContext,
+ out: *mut HTTPC_RequestStatus) -> Result;
+ pub fn httpcGetDownloadSizeState(context: *mut httpcContext,
+ downloadedsize: *mut u32,
+ contentsize: *mut u32) -> Result;
+ pub fn httpcGetResponseStatusCode(context: *mut httpcContext,
+ out: *mut u32, delay: u64) -> Result;
+ pub fn httpcGetResponseHeader(context: *mut httpcContext,
+ name: *mut u8,
+ value: *mut u8,
+ valuebuf_maxsize: u32) -> Result;
+ pub fn httpcDownloadData(context: *mut httpcContext, buffer: *mut u8,
+ size: u32, downloadedsize: *mut u32) -> Result;
+ pub fn HTTPC_Initialize(handle: Handle) -> Result;
+ pub fn HTTPC_InitializeConnectionSession(handle: Handle,
+ contextHandle: Handle) -> Result;
+ pub fn HTTPC_CreateContext(handle: Handle,
+ url: *mut u8,
+ contextHandle: *mut Handle) -> Result;
+ pub fn HTTPC_CloseContext(handle: Handle, contextHandle: Handle)
+ -> Result;
+ pub fn HTTPC_SetProxyDefault(handle: Handle, contextHandle: Handle)
+ -> Result;
+ pub fn HTTPC_AddRequestHeaderField(handle: Handle, contextHandle: Handle,
+ name: *mut u8,
+ value: *mut u8)
+ -> Result;
+ pub fn HTTPC_BeginRequest(handle: Handle, contextHandle: Handle)
+ -> Result;
+ pub fn HTTPC_ReceiveData(handle: Handle, contextHandle: Handle,
+ buffer: *mut u8, size: u32) -> Result;
+ pub fn HTTPC_GetRequestState(handle: Handle, contextHandle: Handle,
+ out: *mut HTTPC_RequestStatus) -> Result;
+ pub fn HTTPC_GetDownloadSizeState(handle: Handle, contextHandle: Handle,
+ downloadedsize: *mut u32,
+ contentsize: *mut u32) -> Result;
+ pub fn HTTPC_GetResponseHeader(handle: Handle, contextHandle: Handle,
+ name: *mut u8,
+ value: *mut u8,
+ valuebuf_maxsize: u32) -> Result;
+ pub fn HTTPC_GetResponseStatusCode(handle: Handle, contextHandle: Handle,
+ out: *mut u32) -> Result;
+}
diff --git a/ctru-sys/src/services/ir.rs b/ctru-sys/src/services/ir.rs
index 3affb65..94a626a 100644
--- a/ctru-sys/src/services/ir.rs
+++ b/ctru-sys/src/services/ir.rs
@@ -1,14 +1,21 @@
use ::{Result, Handle};
-
extern "C" {
- pub fn IRU_Initialize(sharedmem_addr: *mut u32, sharedmem_size: u32) -> Result;
+ pub fn iruInit(sharedmem_addr: *mut u32, sharedmem_size: u32) -> Result;
+ pub fn iruExit();
+ pub fn iruGetServHandle() -> Handle;
+ pub fn iruSendData(buf: *mut u8, size: u32, wait: u8) -> Result;
+ pub fn iruRecvData(buf: *mut u8, size: u32, flag: u8,
+ transfercount: *mut u32, wait: u8) -> Result;
+ pub fn IRU_Initialize() -> Result;
pub fn IRU_Shutdown() -> Result;
- pub fn IRU_GetServHandle() -> Handle;
- pub fn IRU_SendData(buf: *mut u8, size: u32, wait: u32) -> Result;
- pub fn IRU_RecvData(buf: *mut u8, size: u32, flag: u8, transfercount: *mut u32, wait: u32) -> Result;
+ pub fn IRU_StartSendTransfer(buf: *mut u8, size: u32) -> Result;
+ pub fn IRU_WaitSendTransfer() -> Result;
+ pub fn IRU_StartRecvTransfer(size: u32, flag: u8) -> Result;
+ pub fn IRU_WaitRecvTransfer(transfercount: *mut u32) -> Result;
pub fn IRU_SetBitRate(value: u8) -> Result;
pub fn IRU_GetBitRate(out: *mut u8) -> Result;
pub fn IRU_SetIRLEDState(value: u32) -> Result;
pub fn IRU_GetIRLEDRecvState(out: *mut u32) -> Result;
}
+
diff --git a/ctru-sys/src/services/irrst.rs b/ctru-sys/src/services/irrst.rs
index b986270..2f4c6eb 100644
--- a/ctru-sys/src/services/irrst.rs
+++ b/ctru-sys/src/services/irrst.rs
@@ -3,19 +3,19 @@ use ::types::*;
use super::hid::circlePosition;
-
extern "C" {
- pub static irrstMemHandle: Handle;
- pub static irrstSharedMem: *mut vu32;
+ pub static mut irrstMemHandle: Handle;
+ pub static mut irrstSharedMem: *mut vu32;
- pub fn irrstInit(sharedMem: *mut u32) -> Result;
- pub fn irrstExit() -> ();
- pub fn irrstScanInput() -> ();
+ pub fn irrstInit() -> Result;
+ pub fn irrstExit();
+ pub fn irrstScanInput();
pub fn irrstKeysHeld() -> u32;
- pub fn irrstCstickRead(pos: *mut circlePosition) -> ();
- pub fn irrstWaitForEvent(nextEvent: u8) -> ();
+ pub fn irrstCstickRead(pos: *mut circlePosition);
+ pub fn irrstWaitForEvent(nextEvent: u8);
pub fn IRRST_GetHandles(outMemHandle: *mut Handle,
outEventHandle: *mut Handle) -> Result;
pub fn IRRST_Initialize(unk1: u32, unk2: u8) -> Result;
pub fn IRRST_Shutdown() -> Result;
+
}
diff --git a/ctru-sys/src/services/mic.rs b/ctru-sys/src/services/mic.rs
index 64e7746..1037698 100644
--- a/ctru-sys/src/services/mic.rs
+++ b/ctru-sys/src/services/mic.rs
@@ -1,19 +1,42 @@
-use ::{Result, Handle};
+use ::{Handle, Result};
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum MICU_Encoding {
+ MICU_ENCODING_PCM8 = 0,
+ MICU_ENCODING_PCM16 = 1,
+ MICU_ENCODING_PCM8_SIGNED = 2,
+ MICU_ENCODING_PCM16_SIGNED = 3,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum MICU_SampleRate {
+ MICU_SAMPLE_RATE_32730 = 0,
+ MICU_SAMPLE_RATE_16360 = 1,
+ MICU_SAMPLE_RATE_10910 = 2,
+ MICU_SAMPLE_RATE_8180 = 3,
+}
extern "C" {
- pub fn MIC_Initialize(sharedmem: *mut u32, sharedmem_size: u32, control: u8, recording: u8, unk0: u8, unk1: u8, unk2: u8) -> Result;
- pub fn MIC_Shutdown() -> Result;
- pub fn MIC_GetSharedMemOffsetValue() -> u32;
- pub fn MIC_ReadAudioData(outbuf: *mut u8, readsize: u32, waitforevent: u32) -> u32;
- pub fn MIC_MapSharedMem(handle: Handle, size: u32) -> Result;
- pub fn MIC_UnmapSharedMem() -> Result;
- pub fn MIC_cmd3_Initialize(unk0: u8, unk1: u8, sharedmem_baseoffset: u32, sharedmem_endoffset: u32, unk2: u8) -> Result;
- pub fn MIC_cmd5() -> Result;
- pub fn MIC_GetCNTBit15(out: *mut u8) -> Result;
- pub fn MIC_GetEventHandle(handle: *mut Handle) -> Result;
- pub fn MIC_SetControl(value: u8) -> Result;
- pub fn MIC_GetControl(value: *mut u8) -> Result;
- pub fn MIC_SetRecording(value: u8) -> Result;
- pub fn MIC_IsRecoding(value: *mut u8) -> Result;
+ pub fn micInit(buffer: *mut u8, bufferSize: u32) -> Result;
+ pub fn micExit();
+ pub fn micGetSampleDataSize() -> u32;
+ pub fn micGetLastSampleOffset() -> u32;
+ pub fn MICU_MapSharedMem(size: u32, handle: Handle) -> Result;
+ pub fn MICU_UnmapSharedMem() -> Result;
+ pub fn MICU_StartSampling(encoding: MICU_Encoding,
+ sampleRate: MICU_SampleRate, offset: u32,
+ size: u32, _loop: u8) -> Result;
+ pub fn MICU_AdjustSampling(sampleRate: MICU_SampleRate) -> Result;
+ pub fn MICU_StopSampling() -> Result;
+ pub fn MICU_IsSampling(sampling: *mut u8) -> Result;
+ pub fn MICU_GetEventHandle(handle: *mut Handle) -> Result;
+ pub fn MICU_SetGain(gain: u8) -> Result;
+ pub fn MICU_GetGain(gain: *mut u8) -> Result;
+ pub fn MICU_SetPower(power: u8) -> Result;
+ pub fn MICU_GetPower(power: *mut u8) -> Result;
+ pub fn MICU_SetClamp(clamp: u8) -> Result;
+ pub fn MICU_GetClamp(clamp: *mut u8) -> Result;
+ pub fn MICU_SetAllowShellClosed(allowShellClosed: u8) -> Result;
}
diff --git a/ctru-sys/src/services/mod.rs b/ctru-sys/src/services/mod.rs
index ec2d270..76b7c35 100644
--- a/ctru-sys/src/services/mod.rs
+++ b/ctru-sys/src/services/mod.rs
@@ -1,15 +1,27 @@
pub mod ac;
pub mod am;
pub mod apt;
+pub mod cam;
pub mod cfgnor;
pub mod cfgu;
-pub mod gsp;
+pub mod dsp;
+pub mod fs;
+pub mod gspgpu;
+pub mod gsplcd;
pub mod hb;
pub mod hid;
+pub mod httpc;
pub mod ir;
pub mod irrst;
pub mod mic;
+pub mod mvd;
+pub mod news;
pub mod ns;
pub mod pm;
-pub mod ptm;
+pub mod ps;
+pub mod ptmsysm;
+pub mod ptmu;
+pub mod qtm;
pub mod soc;
+pub mod srvpm;
+pub mod y2r;
diff --git a/ctru-sys/src/services/mvd.rs b/ctru-sys/src/services/mvd.rs
new file mode 100644
index 0000000..fe8691c
--- /dev/null
+++ b/ctru-sys/src/services/mvd.rs
@@ -0,0 +1,67 @@
+use ::Result;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum MVDSTD_Mode {
+ MVDMODE_COLORFORMATCONV = 0,
+ MVDMODE_VIDEOPROCESSING = 1,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum MVDSTD_InputFormat {
+ MVD_INPUT_YUYV422 = 65537,
+ MVD_INPUT_H264 = 131073,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum MVDSTD_OutputFormat { MVD_OUTPUT_RGB565 = 262146, }
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct MVDSTD_Config {
+ pub input_type: MVDSTD_InputFormat,
+ pub unk_x04: u32,
+ pub unk_x08: u32,
+ pub inwidth: u32,
+ pub inheight: u32,
+ pub physaddr_colorconv_indata: u32,
+ pub unk_x18: [u32; 10usize],
+ pub flag_x40: u32,
+ pub unk_x44: u32,
+ pub unk_x48: u32,
+ pub outheight0: u32,
+ pub outwidth0: u32,
+ pub unk_x54: u32,
+ pub output_type: MVDSTD_OutputFormat,
+ pub outwidth1: u32,
+ pub outheight1: u32,
+ pub physaddr_outdata0: u32,
+ pub physaddr_outdata1_colorconv: u32,
+ pub unk_x6c: [u32; 44usize],
+}
+impl ::core::clone::Clone for MVDSTD_Config {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for MVDSTD_Config {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+
+extern "C" {
+ pub fn mvdstdInit(mode: MVDSTD_Mode, input_type: MVDSTD_InputFormat,
+ output_type: MVDSTD_OutputFormat, size: u32) -> Result;
+ pub fn mvdstdExit();
+ pub fn mvdstdGenerateDefaultConfig(config: *mut MVDSTD_Config,
+ input_width: u32, input_height: u32,
+ output_width: u32,
+ output_height: u32,
+ vaddr_colorconv_indata: *mut u32,
+ vaddr_outdata0: *mut u32,
+ vaddr_outdata1_colorconv: *mut u32);
+ pub fn mvdstdProcessFrame(config: *mut MVDSTD_Config,
+ h264_vaddr_inframe: *mut u32,
+ h264_inframesize: u32, h264_frameid: u32)
+ -> Result;
+ pub fn MVDSTD_SetConfig(config: *mut MVDSTD_Config) -> Result;
+}
diff --git a/ctru-sys/src/services/news.rs b/ctru-sys/src/services/news.rs
new file mode 100644
index 0000000..fc82784
--- /dev/null
+++ b/ctru-sys/src/services/news.rs
@@ -0,0 +1,11 @@
+use ::Result;
+use ::c_void;
+
+extern "C" {
+ pub fn newsInit() -> Result;
+ pub fn newsExit();
+ pub fn NEWS_AddNotification(title: *const u16, titleLength: u32,
+ message: *const u16, messageLength: u32,
+ imageData: *const c_void,
+ imageSize: u32, jpeg: u8) -> Result;
+}
diff --git a/ctru-sys/src/services/ns.rs b/ctru-sys/src/services/ns.rs
index 68a58c2..c48e176 100644
--- a/ctru-sys/src/services/ns.rs
+++ b/ctru-sys/src/services/ns.rs
@@ -1,9 +1,9 @@
use ::Result;
-
extern "C" {
pub fn nsInit() -> Result;
- pub fn nsExit() -> Result;
+ pub fn nsExit();
pub fn NS_LaunchTitle(titleid: u64, launch_flags: u32, procid: *mut u32) -> Result;
pub fn NS_RebootToTitle(mediatype: u8, titleid: u64) -> Result;
}
+
diff --git a/ctru-sys/src/services/pm.rs b/ctru-sys/src/services/pm.rs
index 78eb3fd..971fbb3 100644
--- a/ctru-sys/src/services/pm.rs
+++ b/ctru-sys/src/services/pm.rs
@@ -1,12 +1,24 @@
-use ::Result;
-
+use ::{Handle, Result};
+use ::c_void;
extern "C" {
pub fn pmInit() -> Result;
- pub fn pmExit() -> Result;
- pub fn PM_LaunchTitle(mediatype: u8, titleid: u64, launch_flags: u32) -> Result;
- pub fn PM_GetTitleExheaderFlags(mediatype: u8, titleid: u64, out: *mut u8) -> Result;
+ pub fn pmExit();
+ pub fn PM_LaunchTitle(mediatype: u8, titleid: u64, launch_flags: u32)
+ -> Result;
+ pub fn PM_GetTitleExheaderFlags(mediatype: u8, titleid: u64,
+ out: *mut u8) -> Result;
pub fn PM_SetFIRMLaunchParams(size: u32, _in: *mut u8) -> Result;
pub fn PM_GetFIRMLaunchParams(size: u32, out: *mut u8) -> Result;
- pub fn PM_LaunchFIRMSetParams(firm_titleid_low: u32, size: u32, _in: *mut u8) -> Result;
+ pub fn PM_LaunchFIRMSetParams(firm_titleid_low: u32, size: u32,
+ _in: *mut u8) -> Result;
+ pub fn srvPmInit() -> Result;
+ pub fn srvPmExit();
+ pub fn SRVPM_PublishToProcess(notificationId: u32, process: Handle)
+ -> Result;
+ pub fn SRVPM_PublishToAll(notificationId: u32) -> Result;
+ pub fn SRVPM_RegisterProcess(procid: u32, count: u32,
+ serviceaccesscontrol: c_void) -> Result;
+ pub fn SRVPM_UnregisterProcess(procid: u32) -> Result;
}
+
diff --git a/ctru-sys/src/services/ps.rs b/ctru-sys/src/services/ps.rs
new file mode 100644
index 0000000..e59a08d
--- /dev/null
+++ b/ctru-sys/src/services/ps.rs
@@ -0,0 +1,46 @@
+use ::Result;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum PS_AESAlgorithm {
+ PS_ALGORITHM_CBC_ENC = 0,
+ PS_ALGORITHM_CBC_DEC = 1,
+ PS_ALGORITHM_CTR_ENC = 2,
+ PS_ALGORITHM_CTR_DEC = 3,
+ PS_ALGORITHM_CCM_ENC = 4,
+ PS_ALGORITHM_CCM_DEC = 5,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum PS_AESKeyType {
+ PS_KEYSLOT_0D = 0,
+ PS_KEYSLOT_2D = 1,
+ PS_KEYSLOT_31 = 2,
+ PS_KEYSLOT_38 = 3,
+ PS_KEYSLOT_32 = 4,
+ PS_KEYSLOT_39_DLP = 5,
+ PS_KEYSLOT_2E = 6,
+ PS_KEYSLOT_INVALID = 7,
+ PS_KEYSLOT_36 = 8,
+ PS_KEYSLOT_39_NFC = 9,
+}
+
+extern "C" {
+ pub fn psInit() -> Result;
+ pub fn psExit();
+ pub fn PS_EncryptDecryptAes(size: u32, _in: *mut u8, out: *mut u8,
+ aes_algo: PS_AESAlgorithm,
+ key_type: PS_AESKeyType, iv: *mut u8)
+ -> Result;
+ pub fn PS_EncryptSignDecryptVerifyAesCcm(_in: *mut u8, in_size: u32,
+ out: *mut u8, out_size: u32,
+ data_len: u32,
+ mac_data_len: u32,
+ mac_len: u32,
+ aes_algo: PS_AESAlgorithm,
+ key_type: PS_AESKeyType,
+ nonce: *mut u8) -> Result;
+ pub fn PS_GetLocalFriendCodeSeed(seed: *mut u64) -> Result;
+ pub fn PS_GetDeviceId(device_id: *mut u32) -> Result;
+}
diff --git a/ctru-sys/src/services/ptm.rs b/ctru-sys/src/services/ptm.rs
deleted file mode 100644
index 2743648..0000000
--- a/ctru-sys/src/services/ptm.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-use ::{Result, Handle};
-
-
-extern "C" {
- pub fn ptmInit() -> Result;
- pub fn ptmExit() -> Result;
- pub fn PTMU_GetShellState(servhandle: *mut Handle, out: *mut u8) -> Result;
- pub fn PTMU_GetBatteryLevel(servhandle: *mut Handle, out: *mut u8) -> Result;
- pub fn PTMU_GetBatteryChargeState(servhandle: *mut Handle, out: *mut u8) -> Result;
- pub fn PTMU_GetPedometerState(servhandle: *mut Handle, out: *mut u8) -> Result;
- pub fn PTMU_GetTotalStepCount(servhandle: *mut Handle, steps: *mut u32) -> Result;
-}
diff --git a/ctru-sys/src/services/ptmsysm.rs b/ctru-sys/src/services/ptmsysm.rs
new file mode 100644
index 0000000..7507fd5
--- /dev/null
+++ b/ctru-sys/src/services/ptmsysm.rs
@@ -0,0 +1,7 @@
+use ::Result;
+
+extern "C" {
+ pub fn ptmSysmInit() -> Result;
+ pub fn ptmSysmExit();
+ pub fn PTMSYSM_ConfigureNew3DSCPU(value: u8) -> Result;
+}
diff --git a/ctru-sys/src/services/ptmu.rs b/ctru-sys/src/services/ptmu.rs
new file mode 100644
index 0000000..e230a37
--- /dev/null
+++ b/ctru-sys/src/services/ptmu.rs
@@ -0,0 +1,11 @@
+use ::Result;
+
+extern "C" {
+ pub fn ptmuInit() -> Result;
+ pub fn ptmuExit();
+ pub fn PTMU_GetShellState(out: *mut u8) -> Result;
+ pub fn PTMU_GetBatteryLevel(out: *mut u8) -> Result;
+ pub fn PTMU_GetBatteryChargeState(out: *mut u8) -> Result;
+ pub fn PTMU_GetPedometerState(out: *mut u8) -> Result;
+ pub fn PTMU_GetTotalStepCount(steps: *mut u32) -> Result;
+}
diff --git a/ctru-sys/src/services/qtm.rs b/ctru-sys/src/services/qtm.rs
new file mode 100644
index 0000000..30d7595
--- /dev/null
+++ b/ctru-sys/src/services/qtm.rs
@@ -0,0 +1,44 @@
+use ::Result;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct QTM_HeadTrackingInfoCoord {
+ pub x: f32,
+ pub y: f32,
+}
+impl ::core::clone::Clone for QTM_HeadTrackingInfoCoord {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for QTM_HeadTrackingInfoCoord {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct QTM_HeadTrackingInfo {
+ pub flags: [u8; 5usize],
+ pub padding: [u8; 3usize],
+ pub floatdata_x08: f32,
+ pub coords0: [QTM_HeadTrackingInfoCoord; 4usize],
+ pub unk_x2c: [u32; 5usize],
+}
+impl ::core::clone::Clone for QTM_HeadTrackingInfo {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for QTM_HeadTrackingInfo {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+
+extern "C" {
+ pub fn qtmInit() -> Result;
+ pub fn qtmExit();
+ pub fn qtmCheckInitialized() -> u8;
+ pub fn qtmCheckHeadFullyDetected(info: *mut QTM_HeadTrackingInfo) -> u8;
+ pub fn qtmConvertCoordToScreen(coord: *mut QTM_HeadTrackingInfoCoord,
+ screen_width: *mut f32,
+ screen_height:
+ *mut f32,
+ x: *mut u32, y: *mut u32) -> Result;
+ pub fn QTM_GetHeadTrackingInfo(val: u64, out: *mut QTM_HeadTrackingInfo)
+ -> Result;
+}
diff --git a/ctru-sys/src/services/soc.rs b/ctru-sys/src/services/soc.rs
index aff4f1d..3a1e2ec 100644
--- a/ctru-sys/src/services/soc.rs
+++ b/ctru-sys/src/services/soc.rs
@@ -1,7 +1,7 @@
use ::Result;
-
extern "C" {
- pub fn SOC_Initialize(context_addr: *mut u32, context_size: u32) -> Result;
- pub fn SOC_Shutdown() -> Result;
+ pub fn SOC_Init(context_addr: *mut u32, context_size: u32) -> Result;
+ pub fn SOC_Exit() -> Result;
+ pub fn gethostid() -> i32;
}
diff --git a/ctru-sys/src/services/srvpm.rs b/ctru-sys/src/services/srvpm.rs
new file mode 100644
index 0000000..0141898
--- /dev/null
+++ b/ctru-sys/src/services/srvpm.rs
@@ -0,0 +1,12 @@
+use ::{Handle, Result};
+use ::c_void;
+
+extern "C" {
+ pub fn srvPmInit() -> Result;
+ pub fn srvPmExit();
+ pub fn SRVPM_PublishToProcess(notificationId: u32, process: Handle) -> Result;
+ pub fn SRVPM_PublishToAll(notificationId: u32) -> Result;
+ pub fn SRVPM_RegisterProcess(procid: u32, count: u32,
+ serviceaccesscontrol: c_void) -> Result;
+ pub fn SRVPM_UnregisterProcess(procid: u32) -> Result;
+}
diff --git a/ctru-sys/src/services/y2r.rs b/ctru-sys/src/services/y2r.rs
new file mode 100644
index 0000000..d3393d3
--- /dev/null
+++ b/ctru-sys/src/services/y2r.rs
@@ -0,0 +1,185 @@
+use ::{Handle, Result};
+use ::c_void;
+use ::types::*;
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Y2RU_InputFormat {
+ INPUT_YUV422_INDIV_8 = 0,
+ INPUT_YUV420_INDIV_8 = 1,
+ INPUT_YUV422_INDIV_16 = 2,
+ INPUT_YUV420_INDIV_16 = 3,
+ INPUT_YUV422_BATCH = 4,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Y2RU_OutputFormat {
+ OUTPUT_RGB_32 = 0,
+ OUTPUT_RGB_24 = 1,
+ OUTPUT_RGB_16_555 = 2,
+ OUTPUT_RGB_16_565 = 3,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Y2RU_Rotation {
+ ROTATION_NONE = 0,
+ ROTATION_CLOCKWISE_90 = 1,
+ ROTATION_CLOCKWISE_180 = 2,
+ ROTATION_CLOCKWISE_270 = 3,
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Y2RU_BlockAlignment {
+ BLOCK_LINE = 0,
+ BLOCK_8_BY_8 = 1,
+}
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Y2RU_ColorCoefficients {
+ pub rgb_Y: u16,
+ pub r_V: u16,
+ pub g_V: u16,
+ pub g_U: u16,
+ pub b_U: u16,
+ pub r_offset: u16,
+ pub g_offset: u16,
+ pub b_offset: u16,
+}
+impl ::core::clone::Clone for Y2RU_ColorCoefficients {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Y2RU_ColorCoefficients {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Y2RU_StandardCoefficient {
+ COEFFICIENT_ITU_R_BT_601 = 0,
+ COEFFICIENT_ITU_R_BT_709 = 1,
+ COEFFICIENT_ITU_R_BT_601_SCALING = 2,
+ COEFFICIENT_ITU_R_BT_709_SCALING = 3,
+}
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Y2RU_ConversionParams {
+ pub _bindgen_bitfield_1_: Y2RU_InputFormat,
+ pub _bindgen_bitfield_2_: Y2RU_OutputFormat,
+ pub _bindgen_bitfield_3_: Y2RU_Rotation,
+ pub _bindgen_bitfield_4_: Y2RU_BlockAlignment,
+ pub input_line_width: s16,
+ pub input_lines: s16,
+ pub _bindgen_bitfield_5_: Y2RU_StandardCoefficient,
+ pub unused: u8,
+ pub alpha: u16,
+}
+impl ::core::clone::Clone for Y2RU_ConversionParams {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Y2RU_ConversionParams {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Y2RU_DitheringWeightParams {
+ pub w0_xEven_yEven: u16,
+ pub w0_xOdd_yEven: u16,
+ pub w0_xEven_yOdd: u16,
+ pub w0_xOdd_yOdd: u16,
+ pub w1_xEven_yEven: u16,
+ pub w1_xOdd_yEven: u16,
+ pub w1_xEven_yOdd: u16,
+ pub w1_xOdd_yOdd: u16,
+ pub w2_xEven_yEven: u16,
+ pub w2_xOdd_yEven: u16,
+ pub w2_xEven_yOdd: u16,
+ pub w2_xOdd_yOdd: u16,
+ pub w3_xEven_yEven: u16,
+ pub w3_xOdd_yEven: u16,
+ pub w3_xEven_yOdd: u16,
+ pub w3_xOdd_yOdd: u16,
+}
+impl ::core::clone::Clone for Y2RU_DitheringWeightParams {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Y2RU_DitheringWeightParams {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+
+extern "C" {
+ pub fn y2rInit() -> Result;
+ pub fn y2rExit();
+ pub fn Y2RU_SetInputFormat(format: Y2RU_InputFormat) -> Result;
+ pub fn Y2RU_GetInputFormat(format: *mut Y2RU_InputFormat) -> Result;
+ pub fn Y2RU_SetOutputFormat(format: Y2RU_OutputFormat) -> Result;
+ pub fn Y2RU_GetOutputFormat(format: *mut Y2RU_OutputFormat) -> Result;
+ pub fn Y2RU_SetRotation(rotation: Y2RU_Rotation) -> Result;
+ pub fn Y2RU_GetRotation(rotation: *mut Y2RU_Rotation) -> Result;
+ pub fn Y2RU_SetBlockAlignment(alignment: Y2RU_BlockAlignment) -> Result;
+ pub fn Y2RU_GetBlockAlignment(alignment: *mut Y2RU_BlockAlignment)
+ -> Result;
+ pub fn Y2RU_SetSpacialDithering(enable: u8) -> Result;
+ pub fn Y2RU_GetSpacialDithering(enabled: *mut u8) -> Result;
+ pub fn Y2RU_SetTemporalDithering(enable: u8) -> Result;
+ pub fn Y2RU_GetTemporalDithering(enabled: *mut u8) -> Result;
+ pub fn Y2RU_SetInputLineWidth(line_width: u16) -> Result;
+ pub fn Y2RU_GetInputLineWidth(line_width: *mut u16) -> Result;
+ pub fn Y2RU_SetInputLines(num_lines: u16) -> Result;
+ pub fn Y2RU_GetInputLines(num_lines: *mut u16) -> Result;
+ pub fn Y2RU_SetCoefficients(coefficients: *const Y2RU_ColorCoefficients)
+ -> Result;
+ pub fn Y2RU_GetCoefficients(coefficients: *mut Y2RU_ColorCoefficients)
+ -> Result;
+ pub fn Y2RU_SetStandardCoefficient(coefficient: Y2RU_StandardCoefficient)
+ -> Result;
+ pub fn Y2RU_GetStandardCoefficient(coefficients:
+ *mut Y2RU_ColorCoefficients,
+ standardCoeff:
+ Y2RU_StandardCoefficient)
+ -> Result;
+ pub fn Y2RU_SetAlpha(alpha: u16) -> Result;
+ pub fn Y2RU_GetAlpha(alpha: *mut u16) -> Result;
+ pub fn Y2RU_SetTransferEndInterrupt(should_interrupt: u8) -> Result;
+ pub fn Y2RU_GetTransferEndInterrupt(should_interrupt: *mut u8) -> Result;
+ pub fn Y2RU_GetTransferEndEvent(end_event: *mut Handle) -> Result;
+ pub fn Y2RU_SetSendingY(src_buf: *const c_void,
+ image_size: u32, transfer_unit: s16,
+ transfer_gap: s16) -> Result;
+ pub fn Y2RU_SetSendingU(src_buf: *const c_void,
+ image_size: u32, transfer_unit: s16,
+ transfer_gap: s16) -> Result;
+ pub fn Y2RU_SetSendingV(src_buf: *const c_void,
+ image_size: u32, transfer_unit: s16,
+ transfer_gap: s16) -> Result;
+ pub fn Y2RU_SetSendingYUYV(src_buf: *const c_void,
+ image_size: u32, transfer_unit: s16,
+ transfer_gap: s16) -> Result;
+ pub fn Y2RU_SetReceiving(dst_buf: *mut c_void,
+ image_size: u32, transfer_unit: s16,
+ transfer_gap: s16) -> Result;
+ pub fn Y2RU_IsDoneSendingY(is_done: *mut u8) -> Result;
+ pub fn Y2RU_IsDoneSendingU(is_done: *mut u8) -> Result;
+ pub fn Y2RU_IsDoneSendingV(is_done: *mut u8) -> Result;
+ pub fn Y2RU_IsDoneSendingYUYV(is_done: *mut u8) -> Result;
+ pub fn Y2RU_IsDoneReceiving(is_done: *mut u8) -> Result;
+ pub fn Y2RU_SetDitheringWeightParams(params:
+ *const Y2RU_DitheringWeightParams)
+ -> Result;
+ pub fn Y2RU_GetDitheringWeightParams(params:
+ *mut Y2RU_DitheringWeightParams)
+ -> Result;
+ pub fn Y2RU_SetConversionParams(params: *const Y2RU_ConversionParams)
+ -> Result;
+ pub fn Y2RU_StartConversion() -> Result;
+ pub fn Y2RU_StopConversion() -> Result;
+ pub fn Y2RU_IsBusyConversion(is_busy: *mut u8) -> Result;
+ pub fn Y2RU_PingProcess(ping: *mut u8) -> Result;
+ pub fn Y2RU_DriverInitialize() -> Result;
+ pub fn Y2RU_DriverFinalize() -> Result;
+}
diff --git a/ctru-sys/src/svc.rs b/ctru-sys/src/svc.rs
index a370104..0ad3fc9 100644
--- a/ctru-sys/src/svc.rs
+++ b/ctru-sys/src/svc.rs
@@ -1,312 +1,450 @@
+//TODO: Implement static functions
+
use {Handle, Result};
+use c_void;
+use ThreadFunc;
use types::*;
+#[derive(Clone, Copy)]
#[repr(C)]
-pub enum MemOp {
+pub enum Enum_Unnamed1 {
MEMOP_FREE = 1,
+ MEMOP_RESERVE = 2,
MEMOP_ALLOC = 3,
MEMOP_MAP = 4,
MEMOP_UNMAP = 5,
MEMOP_PROT = 6,
-
- MEMOP_ALLOC_LINEAR = 0x10003,
-}
-
+ 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,
+}
+pub type MemOp = Enum_Unnamed1;
+#[derive(Clone, Copy)]
#[repr(C)]
-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
-}
-
+pub enum Enum_Unnamed2 {
+ 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,
+}
+pub type MemState = Enum_Unnamed2;
+#[derive(Clone, Copy)]
#[repr(C)]
-pub enum MemPerm {
- MEMPERM_READ = 1,
- MEMPERM_WRITE = 2,
- MEMPERM_EXECUTE = 4,
- MEMPERM_DONTCARE = 0x10000000,
- MEMPERM_MAX = 0xFFFFFFFF //force 4-byte
+pub enum Enum_Unnamed3 {
+ MEMPERM_READ = 1,
+ MEMPERM_WRITE = 2,
+ MEMPERM_EXECUTE = 4,
+ MEMPERM_DONTCARE = 268435456,
}
-
+pub type MemPerm = Enum_Unnamed3;
#[repr(C)]
-pub struct MemInfo {
+#[derive(Copy)]
+pub struct Struct_Unnamed4 {
pub base_addr: u32,
pub size: u32,
pub perm: u32,
pub state: u32,
}
-
+impl ::core::clone::Clone for Struct_Unnamed4 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed4 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type MemInfo = Struct_Unnamed4;
#[repr(C)]
-#[derive(Clone, Copy)]
-pub struct PageInfo {
+#[derive(Copy)]
+pub struct Struct_Unnamed5 {
pub flags: u32,
}
-
-#[repr(C)]
-pub enum ArbitrationType {
- ARBITER_FREE =0,
- ARBITER_ACQUIRE =1,
- ARBITER_KERNEL2 =2,
- ARBITER_ACQUIRE_TIMEOUT=3,
- ARBITER_KERNEL4 =4,
+impl ::core::clone::Clone for Struct_Unnamed5 {
+ fn clone(&self) -> Self { *self }
}
-
-#[repr(C)]
-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
+impl ::core::default::Default for Struct_Unnamed5 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
-
+pub type PageInfo = Struct_Unnamed5;
+#[derive(Clone, Copy)]
#[repr(C)]
-pub enum ProcessEventReason {
- REASON_CREATE = 1,
- REASON_ATTACH = 2
-}
-
+pub enum Enum_Unnamed6 {
+ 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,
+}
+pub type ArbitrationType = Enum_Unnamed6;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed7 { THREADINFO_TYPE_UNKNOWN = 0, }
+pub type ThreadInfoType = Enum_Unnamed7;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed8 { REASON_CREATE = 1, REASON_ATTACH = 2, }
+pub type ProcessEventReason = Enum_Unnamed8;
#[repr(C)]
#[derive(Copy)]
-pub struct ProcessEvent {
+pub struct Struct_Unnamed9 {
pub program_id: u64,
pub process_name: [u8; 8usize],
pub process_id: u32,
- pub reason: u32
+ pub reason: u32,
}
-
-impl Clone for ProcessEvent {
+impl ::core::clone::Clone for Struct_Unnamed9 {
fn clone(&self) -> Self { *self }
}
-
+impl ::core::default::Default for Struct_Unnamed9 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type ProcessEvent = Struct_Unnamed9;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed10 {
+ EXITPROCESS_EVENT_NONE = 0,
+ EXITPROCESS_EVENT_TERMINATE = 1,
+ EXITPROCESS_EVENT_UNHANDLED_EXCEPTION = 2,
+}
+pub type ExitProcessEventReason = Enum_Unnamed10;
+#[repr(C)]
+#[derive(Copy)]
+pub struct Struct_Unnamed11 {
+ pub reason: u32,
+}
+impl ::core::clone::Clone for Struct_Unnamed11 {
+ fn clone(&self) -> Self { *self }
+}
+impl ::core::default::Default for Struct_Unnamed11 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type ExitProcessEvent = Struct_Unnamed11;
#[repr(C)]
#[derive(Copy)]
-pub struct CreateThreadEvent {
+pub struct Struct_Unnamed12 {
pub creator_thread_id: u32,
pub base_addr: u32,
- pub entry_point: u32
+ pub entry_point: u32,
}
-
-impl Clone for CreateThreadEvent {
+impl ::core::clone::Clone for Struct_Unnamed12 {
fn clone(&self) -> Self { *self }
}
-
-#[repr(C)]
-pub enum ExitThreadEventReason {
- EXITTHREAD_EVENT_NONE = 0,
- EXITTHREAD_EVENT_TERMINATE = 1,
- EXITTHREAD_EVENT_UNHANDLED_EXC = 2,
- EXITTHREAD_EVENT_TERMINATE_PROCESS = 3
+impl ::core::default::Default for Struct_Unnamed12 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
-
+pub type CreateThreadEvent = Struct_Unnamed12;
+#[derive(Clone, Copy)]
#[repr(C)]
-pub enum ExitProcessEventReason {
- EXITPROCESS_EVENT_NONE = 0,
- EXITPROCESS_EVENT_TERMINATE = 1,
- EXITPROCESS_EVENT_UNHANDLED_EXCEPTION = 2
+pub enum Enum_Unnamed13 {
+ EXITTHREAD_EVENT_NONE = 0,
+ EXITTHREAD_EVENT_TERMINATE = 1,
+ EXITTHREAD_EVENT_UNHANDLED_EXC = 2,
+ EXITTHREAD_EVENT_TERMINATE_PROCESS = 3,
}
-
+pub type ExitThreadEventReason = Enum_Unnamed13;
#[repr(C)]
#[derive(Copy)]
-pub struct ExitProcessEvent {
- pub reason: u32
+pub struct Struct_Unnamed14 {
+ pub reason: u32,
}
-
-impl Clone for ExitProcessEvent {
+impl ::core::clone::Clone for Struct_Unnamed14 {
fn clone(&self) -> Self { *self }
}
-
-#[repr(C)]
-#[derive(Copy)]
-pub struct ExitThreadEvent {
- pub reason: u32
+impl ::core::default::Default for Struct_Unnamed14 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
-
-impl Clone for ExitThreadEvent {
- fn clone(&self) -> Self { *self }
+pub type ExitThreadEvent = Struct_Unnamed14;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed15 {
+ USERBREAK_PANIC = 0,
+ USERBREAK_ASSERT = 1,
+ USERBREAK_USER = 2,
}
-
+pub type UserBreakType = Enum_Unnamed15;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed16 {
+ 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,
+}
+pub type ExceptionEventType = Enum_Unnamed16;
#[repr(C)]
#[derive(Copy)]
-pub struct ExceptionEvent {
+pub struct Struct_Unnamed17 {
pub _type: u32,
pub address: u32,
- pub argument: u32
+ pub argument: u32,
}
-
-impl Clone for ExceptionEvent {
+impl ::core::clone::Clone for Struct_Unnamed17 {
fn clone(&self) -> Self { *self }
}
-
-#[repr(C)]
-pub enum ExceptionEventType {
- EXC_EVENT_UNDEFINED_INSTRUCTION = 0, // arg: (None)
- EXC_EVENT_UNKNOWN1 = 1, // arg: (None)
- EXC_EVENT_UNKNOWN2 = 2, // arg: address
- EXC_EVENT_UNKNOWN3 = 3, // arg: address
- EXC_EVENT_ATTACH_BREAK = 4, // arg: (None)
- EXC_EVENT_BREAKPOINT = 5, // arg: (None)
- EXC_EVENT_USER_BREAK = 6, // arg: user break type
- EXC_EVENT_DEBUGGER_BREAK = 7, // arg: (None)
- EXC_EVENT_UNDEFINED_SYSCALL = 8 // arg: attempted syscall
-}
-
-#[repr(C)]
-pub enum UserBreakType {
- USERBREAK_PANIC = 0,
- USERBREAK_ASSERT = 1,
- USERBREAK_USER = 2
-}
-
-/**
-* Type of the query for svcGetThreadInfo
-*/
-#[repr(C)]
-pub enum ThreadInfoType {
- THREADINFO_TYPE_UNKNOWN = 0,
- VARIANT2 = 1, // needed because enums must have 2+ variants for C representation
+impl ::core::default::Default for Struct_Unnamed17 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
}
-
+pub type ExceptionEvent = Struct_Unnamed17;
#[repr(C)]
#[derive(Copy)]
-pub struct SchedulerInOutEvent {
- pub clock_tick: u64
+pub struct Struct_Unnamed18 {
+ pub clock_tick: u64,
}
-
-impl Clone for SchedulerInOutEvent {
+impl ::core::clone::Clone for Struct_Unnamed18 {
fn clone(&self) -> Self { *self }
}
-
+impl ::core::default::Default for Struct_Unnamed18 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type SchedulerInOutEvent = Struct_Unnamed18;
#[repr(C)]
#[derive(Copy)]
-pub struct SyscallInOutEvent {
+pub struct Struct_Unnamed19 {
pub clock_tick: u64,
pub syscall: u32,
}
-
-impl Clone for SyscallInOutEvent {
+impl ::core::clone::Clone for Struct_Unnamed19 {
fn clone(&self) -> Self { *self }
}
-
+impl ::core::default::Default for Struct_Unnamed19 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type SyscallInOutEvent = Struct_Unnamed19;
#[repr(C)]
#[derive(Copy)]
-pub struct OutputStringEvent {
+pub struct Struct_Unnamed20 {
pub string_addr: u32,
- pub string_size: u32
+ pub string_size: u32,
}
-
-impl Clone for OutputStringEvent {
+impl ::core::clone::Clone for Struct_Unnamed20 {
fn clone(&self) -> Self { *self }
}
-
+impl ::core::default::Default for Struct_Unnamed20 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type OutputStringEvent = Struct_Unnamed20;
#[repr(C)]
#[derive(Copy)]
-pub struct MapEvent {
+pub struct Struct_Unnamed21 {
pub mapped_addr: u32,
pub mapped_size: u32,
pub memperm: u32,
- pub memstate: u32
+ pub memstate: u32,
}
-
-impl Clone for MapEvent {
+impl ::core::clone::Clone for Struct_Unnamed21 {
fn clone(&self) -> Self { *self }
}
-
+impl ::core::default::Default for Struct_Unnamed21 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type MapEvent = Struct_Unnamed21;
+#[derive(Clone, Copy)]
+#[repr(C)]
+pub enum Enum_Unnamed22 {
+ 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,
+}
+pub type DebugEventType = Enum_Unnamed22;
#[repr(C)]
#[derive(Copy)]
-pub struct DebugEventInfo {
+pub struct Struct_Unnamed23 {
pub _type: u32,
pub thread_id: u32,
pub unknown: [u32; 2usize],
- pub eventUnion: [u64; 3usize], // must use transmutes to access contents
- // union {
- // ProcessEvent process;
- // CreateThreadEvent create_thread;
- // ExitThreadEvent exit_thread;
- // ExitProcessEvent exit_process;
- // ExceptionEvent exception;
- // /* TODO: DLL_LOAD */
- // /* TODO: DLL_UNLOAD */
- // SchedulerInOutEvent scheduler;
- // SyscallInOutEvent syscall;
- // OutputStringEvent output_string;
- // MapEvent map;
- // };
-}
-
-impl Clone for DebugEventInfo {
+ pub _bindgen_data_1_: [u64; 3usize],
+}
+impl Struct_Unnamed23 {
+ 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::clone::Clone for Struct_Unnamed23 {
fn clone(&self) -> Self { *self }
}
-
-// getLocalThreadStorage and getThreadCommandBuffer can't be implemented
-// due to asm. Custom build step may be necessary.
-
-use ThreadFunc;
-
+impl ::core::default::Default for Struct_Unnamed23 {
+ fn default() -> Self { unsafe { ::core::mem::zeroed() } }
+}
+pub type DebugEventInfo = Struct_Unnamed23;
extern "C" {
- pub fn svcControlMemory(addr_out: *mut u32, addr0: u32, addr1: u32, size: u32, op: MemOp, perm: MemPerm) -> s32;
- pub fn svcQueryMemory(info: *mut MemInfo, out: *mut PageInfo, addr: u32) -> s32;
- pub fn svcExitProcess() -> ();
- pub fn svcCreateThread(thread: *mut Handle, entrypoint: ThreadFunc, arg: u32, stack_top: *mut u32, thread_priority: s32, processor_id: s32) -> s32;
- pub fn svcExitThread() -> ();
- pub fn svcSleepThread(ns: s64) -> ();
- pub fn svcSetThreadPriority(thread: Handle, prio: s32) -> s32;
- pub fn svcCreateMutex(mutex: *mut Handle, initially_locked: u8) -> s32;
- pub fn svcReleaseMutex(handle: Handle) -> s32;
- pub fn svcCreateSemaphore(semaphore: *mut Handle, initial_count: s32, max_count: s32) -> s32;
- pub fn svcReleaseSemaphore(count: *mut s32, semaphore: Handle, release_count: s32) -> s32;
- pub fn svcCreateEvent(event: *mut Handle, reset_type: u8) -> s32;
- pub fn svcSignalEvent(handle: Handle) -> s32;
- pub fn svcClearEvent(handle: Handle) -> s32;
- pub fn svcCreateTimer(timer: *mut Handle, reset_type: u8) -> s32;
- pub fn svcSetTimer(timer: Handle, initial: s64, interval: s64) -> s32;
- pub fn svcCancelTimer(timer: Handle) -> s32;
- pub fn svcClearTimer(timer: Handle) -> s32;
- pub fn svcCreateMemoryBlock(memblock: *mut Handle, addr: u32, size: u32, my_perm: MemPerm, other_perm: MemPerm) -> s32;
- pub fn svcMapMemoryBlock(memblock: Handle, addr: u32, my_perm: MemPerm, other_perm: MemPerm) -> s32;
- pub fn svcUnmapMemoryBlock(memblock: Handle, addr: u32) -> s32;
- pub fn svcCreateAddressArbiter(arbiter: *mut Handle) -> s32;
- pub fn svcArbitrateAddress(arbiter: Handle, addr: u32, _type: ArbitrationType, value: s32, nanoseconds: s64) -> s32;
- pub fn svcWaitSynchronization(handle: Handle, nanoseconds: s64) -> s32;
- pub fn svcWaitSynchronizationN(out: *mut s32, handles: *mut Handle, handles_num: s32, wait_all: u8, nanoseconds: s64) -> s32;
- pub fn svcCloseHandle(handle: Handle) -> s32;
- pub fn svcDuplicateHandle(out: *mut Handle, original: Handle) -> s32;
- pub fn svcGetSystemTick() -> u64;
- pub fn svcGetSystemInfo(out: *mut s64, _type: u32, param: s32) -> s32;
- pub fn svcGetProcessInfo(out: *mut s64, process: Handle, _type: u32) -> s32;
- pub fn svcConnectToPort(out: *mut Handle, portName: *const u8) -> s32;
- pub fn svcSendSyncRequest(session: Handle) -> s32;
+ 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 c_void,
+ srcProcess: Handle,
+ src: *const c_void,
+ size: u32,
+ dmaConfig: *mut c_void)
+ -> Result;
+ pub fn svcStopDma(dma: Handle) -> Result;
+ pub fn svcGetDmaState(dmaState: *mut 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 c_void,
+ size: u32) -> Result;
+ pub fn svcFlushProcessDataCache(process: Handle,
+ addr: *const c_void,
+ size: u32) -> Result;
+ pub fn svcReadProcessMemory(buffer: *mut c_void,
+ debug: Handle, addr: u32, size: u32)
+ -> Result;
+ pub fn svcWriteProcessMemory(debug: Handle,
+ buffer: *const c_void,
+ addr: u32, size: u32) -> Result;
pub fn svcOpenProcess(process: *mut Handle, processId: u32) -> Result;
- pub fn svcGetProcessId(out: *mut u32, handle: Handle) -> s32;
- pub fn svcGetThreadId(out: *mut u32, handle: Handle) -> s32;
- pub fn svcOutputDebugString(string: *const u8, length: i32) -> s32;
- pub fn svcCreatePort(portServer: *mut Handle, portClient: *mut Handle, name: *const u8, maxSessions: s32) -> Result;
- pub fn svcDebugActiveProcess(debug: *mut Handle, processId: u32) -> Result;
+ pub fn svcExitProcess();
+ pub fn svcTerminateProcess(process: Handle) -> Result;
+ pub fn svcGetProcessInfo(out: *mut s64, process: Handle, _type: u32)
+ -> Result;
+ pub fn svcGetProcessId(out: *mut u32, handle: Handle) -> Result;
+ pub fn svcGetProcessList(processCount: *mut s32, processIds: *mut u32,
+ processIdMaxCount: s32) -> Result;
+ pub fn svcCreatePort(portServer: *mut Handle, portClient: *mut Handle,
+ name: *const u8,
+ maxSessions: s32) -> Result;
+ pub fn svcConnectToPort(out: *mut Handle,
+ portName: *const u8)
+ -> Result;
+ pub fn svcCreateThread(thread: *mut Handle, entrypoint: ThreadFunc,
+ arg: u32, stack_top: *mut u32,
+ thread_priority: s32, processor_id: s32) -> Result;
+ pub fn svcOpenThread(thread: *mut Handle, process: Handle, threadId: u32)
+ -> Result;
+ pub fn svcExitThread();
+ pub fn svcSleepThread(ns: s64);
+ pub fn svcGetThreadPriority(out: *mut s32, handle: Handle) -> Result;
+ pub fn svcSetThreadPriority(thread: Handle, prio: s32) -> Result;
+ pub fn svcGetThreadAffinityMask(affinitymask: *mut u8, thread: Handle,
+ processorcount: s32) -> Result;
+ pub fn svcSetThreadAffinityMask(thread: Handle, affinitymask: *mut u8,
+ processorcount: s32) -> Result;
+ pub fn svcGetThreadIdealProcessor(processorid: *mut s32, thread: Handle)
+ -> Result;
+ pub fn svcSetThreadIdealProcessor(thread: Handle, processorid: s32)
+ -> Result;
+ pub fn svcGetProcessorID() -> s32;
+ pub fn svcGetThreadId(out: *mut u32, handle: Handle) -> Result;
+ pub fn svcGetProcessIdOfThread(out: *mut u32, handle: Handle) -> Result;
+ pub fn svcGetThreadInfo(out: *mut s64, 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: s32,
+ max_count: s32) -> Result;
+ pub fn svcReleaseSemaphore(count: *mut s32, semaphore: Handle,
+ release_count: s32) -> Result;
+ pub fn svcCreateEvent(event: *mut Handle, reset_type: u8) -> Result;
+ pub fn svcSignalEvent(handle: Handle) -> Result;
+ pub fn svcClearEvent(handle: Handle) -> Result;
+ pub fn svcWaitSynchronization(handle: Handle, nanoseconds: s64) -> Result;
+ pub fn svcWaitSynchronizationN(out: *mut s32, handles: *mut Handle,
+ handles_num: s32, wait_all: u8,
+ nanoseconds: s64) -> Result;
+ pub fn svcCreateAddressArbiter(arbiter: *mut Handle) -> Result;
+ pub fn svcArbitrateAddress(arbiter: Handle, addr: u32,
+ _type: ArbitrationType, value: s32,
+ nanoseconds: s64) -> Result;
+ pub fn svcSendSyncRequest(session: Handle) -> Result;
+ pub fn svcAcceptSession(session: *mut Handle, port: Handle) -> Result;
+ pub fn svcReplyAndReceive(index: *mut s32, handles: *mut Handle,
+ handleCount: s32, replyTarget: Handle)
+ -> Result;
+ pub fn svcCreateTimer(timer: *mut Handle, reset_type: u8) -> Result;
+ pub fn svcSetTimer(timer: Handle, initial: s64, interval: s64) -> 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 s64, _type: u32, param: s32) -> Result;
+ pub fn svcKernelSetState(_type: u32, param0: u32, param1: u32,
+ param2: u32) -> Result;
+ pub fn svcBreak(breakReason: UserBreakType);
+ pub fn svcOutputDebugString(str: *const u8,
+ length: i32) -> 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 svcGetProcessDebugEvent(info: *mut DebugEventInfo, debug: Handle)
+ -> Result;
pub fn svcContinueDebugEvent(debug: Handle, flags: u32) -> Result;
- pub fn svcGetProcessList(processCount: *mut s32, processIds: *mut u32, processIdMaxCount: s32) -> Result;
- pub fn svcReadProcessMemory(buffer: *mut u8, debug: Handle, addr: u32, size: u32) -> Result;
- pub fn svcMapProcessMemory(process: Handle, startAddr: u32, endAddr: u32) -> Result;
- pub fn svcUnmapProcessMemory(process: Handle, startAddr: u32, endAddr: u32) -> Result;
- pub fn svcQueryProcessMemory(info: *mut MemInfo, out: *mut PageInfo, process: Handle, addr: u32) -> Result;
- pub fn svcGetProcessorID() -> s32;
+ pub fn svcBackdoor(callback:
+ ::core::option::Option<extern "C" fn() -> s32>)
+ -> Result;
}
diff --git a/ctru-sys/src/synchronization.rs b/ctru-sys/src/synchronization.rs
new file mode 100644
index 0000000..6715d53
--- /dev/null
+++ b/ctru-sys/src/synchronization.rs
@@ -0,0 +1,19 @@
+//TODO: Implement stuff that bindgen doesn't catch
+
+use Handle;
+
+use super::lock::*;
+
+pub type LightLock = _LOCK_T;
+pub type RecursiveLock = _LOCK_RECURSIVE_T;
+extern "C" {
+ pub fn __sync_get_arbiter() -> Handle;
+ pub fn LightLock_Init(lock: *mut LightLock);
+ pub fn LightLock_Lock(lock: *mut LightLock);
+ pub fn LightLock_TryLock(lock: *mut LightLock) -> i32;
+ pub fn LightLock_Unlock(lock: *mut LightLock);
+ pub fn RecursiveLock_Init(lock: *mut RecursiveLock);
+ pub fn RecursiveLock_Lock(lock: *mut RecursiveLock);
+ pub fn RecursiveLock_TryLock(lock: *mut RecursiveLock) -> i32;
+ pub fn RecursiveLock_Unlock(lock: *mut RecursiveLock);
+}
diff --git a/ctru-sys/src/thread.rs b/ctru-sys/src/thread.rs
new file mode 100644
index 0000000..960807b
--- /dev/null
+++ b/ctru-sys/src/thread.rs
@@ -0,0 +1,19 @@
+use {Handle, Result};
+use c_void;
+use ThreadFunc;
+
+pub enum Struct_Thread_tag { }
+pub type Thread = *mut Struct_Thread_tag;
+extern "C" {
+ pub fn threadCreate(entrypoint: ThreadFunc,
+ arg: *mut c_void, stack_size: usize,
+ prio: i32,
+ affinity: i32, detached: u8)
+ -> Thread;
+ pub fn threadGetHandle(thread: Thread) -> Handle;
+ pub fn threadGetExitCode(thread: Thread) -> i32;
+ pub fn threadFree(thread: Thread);
+ pub fn threadJoin(thread: Thread, timeout_ns: u64) -> Result;
+ pub fn threadGetCurrent() -> Thread;
+ pub fn threadExit(rc: i32);
+}