forked from obhq/obliteration
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements dce + hmd devices (obhq#859)
Co-authored-by: tompro <[email protected]>
- Loading branch information
1 parent
4bbb9d1
commit fa5ea8e
Showing
16 changed files
with
487 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
use crate::{ | ||
errno::Errno, | ||
fs::{ | ||
make_dev, CharacterDevice, DeviceDriver, DriverFlags, IoCmd, MakeDevError, MakeDevFlags, | ||
Mode, OpenFlags, | ||
}, | ||
process::VThread, | ||
ucred::{Gid, Uid}, | ||
}; | ||
use std::sync::Arc; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug)] | ||
struct Dce {} | ||
|
||
impl Dce { | ||
fn new() -> Self { | ||
Self {} | ||
} | ||
} | ||
|
||
impl DeviceDriver for Dce { | ||
#[allow(unused_variables)] // TODO: remove when implementing | ||
fn open( | ||
&self, | ||
dev: &Arc<CharacterDevice>, | ||
mode: OpenFlags, | ||
devtype: i32, | ||
td: Option<&VThread>, | ||
) -> Result<(), Box<dyn Errno>> { | ||
todo!() | ||
} | ||
|
||
fn ioctl( | ||
&self, | ||
_: &Arc<CharacterDevice>, | ||
cmd: IoCmd, | ||
_: Option<&VThread>, | ||
) -> Result<(), Box<dyn Errno>> { | ||
match cmd { | ||
IoCmd::DCEFLIPCONTROL(_) => todo!("DCEFLIPCONTROL ioctl"), | ||
IoCmd::DCESUBMITFLIP(_) => todo!("DCESUBMITFLIP ioctl"), | ||
IoCmd::DCEREGBUFPTRS(_) => todo!("DCEREGBUFPOINTERS ioctl"), | ||
IoCmd::DCEREGBUFATTR(_) => todo!("DCEREGBUFATTR ioctl"), | ||
IoCmd::DCEDEREGIDENT(_) => todo!("DCEDEREGIDENT ioctl"), | ||
_ => todo!(), | ||
} | ||
} | ||
} | ||
|
||
pub struct DceManager { | ||
dce: Arc<CharacterDevice>, | ||
} | ||
|
||
impl DceManager { | ||
pub fn new() -> Result<Arc<Self>, DceInitError> { | ||
let dce = make_dev( | ||
Dce::new(), | ||
DriverFlags::INIT, | ||
0, | ||
"dce", | ||
Uid::ROOT, | ||
Gid::ROOT, | ||
Mode::new(0o666).unwrap(), | ||
None, | ||
MakeDevFlags::empty(), | ||
)?; | ||
|
||
Ok(Arc::new(Self { dce })) | ||
} | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Debug)] | ||
pub struct DceFlipControlArg { | ||
id: u32, | ||
arg1: usize, | ||
arg2: usize, | ||
arg3: usize, | ||
arg4: u64, | ||
arg5: u64, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Debug)] | ||
pub struct DceSubmitFlipArg { | ||
canary: usize, | ||
buffer_index: usize, | ||
flip_mode: u32, | ||
arg1: usize, | ||
arg2: usize, | ||
eop_nz: u32, | ||
eop_val: usize, | ||
unk: usize, | ||
rout: usize, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Debug)] | ||
pub struct DceRegisterBufferPtrsArg { | ||
canary: usize, | ||
index: u32, | ||
attrid: u32, | ||
left: usize, | ||
right: usize, | ||
unk: u32, | ||
_align: u64, | ||
} | ||
|
||
/// Represents an error when [`DceManager`] fails to initialize. | ||
#[derive(Debug, Error)] | ||
pub enum DceInitError { | ||
#[error("cannot create dce device")] | ||
CreateDceFailed(#[from] MakeDevError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.