From d0bfb6a437c68fb9b0bb54e6bb8b66261ccf2a60 Mon Sep 17 00:00:00 2001 From: Ronald Kinard Date: Thu, 17 Sep 2015 23:10:58 -0500 Subject: [PATCH] Add Sdmc struct. This won't be useful until we have libstd, but worth making since it's trivial. --- src/lib.rs | 3 +++ src/sdmc.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/sdmc.rs 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() + }; + } +}