diff --git a/src/lib.rs b/src/lib.rs index 7ad27ea..65fbda3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,10 +11,13 @@ pub type Handle = u32; pub mod srv; pub mod gfx; +pub mod sdmc; + pub mod services; pub use srv::Srv; pub use gfx::Gfx; +pub use sdmc::Sdmc; #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} diff --git a/src/sdmc.rs b/src/sdmc.rs new file mode 100644 index 0000000..e023010 --- /dev/null +++ b/src/sdmc.rs @@ -0,0 +1,28 @@ +use core::marker::PhantomData; + +use ::raw::sdmc::*; + +pub struct Sdmc { + pd: PhantomData +} + +impl Sdmc { + pub fn new() -> Result { + unsafe { + let r = sdmcInit(); + if r < 0 { + Err(r) + } else { + Ok(Sdmc { pd: PhantomData }) + } + } + } +} + +impl Drop for Sdmc { + fn drop(&mut self) { + unsafe { + sdmcExit() + }; + } +}