Move init implementation into hba and introduce volatile.
This commit is contained in:
parent
34bd3b80d3
commit
741b605a1c
3 changed files with 86 additions and 30 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use bitfield_struct::bitfield;
|
||||
use mammoth::mem::Volatile;
|
||||
|
||||
const fn increment(val: u8) -> u8 {
|
||||
val + 1
|
||||
|
|
@ -144,15 +145,37 @@ pub struct AhciBiosHandoffControl {
|
|||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
pub struct AhciHba {
|
||||
pub capabilities: AhciCapabilities,
|
||||
pub global_host_control: AhciGlobalControl,
|
||||
pub interrupt_status: u32,
|
||||
pub port_implemented: u32,
|
||||
pub version: u32,
|
||||
pub ccc_ctl: u32, // 0x14, Command completion coalescing control
|
||||
pub ccc_pts: u32, // 0x18, Command completion coalescing ports
|
||||
pub em_loc: u32, // 0x1C, Enclosure management location
|
||||
pub em_ctl: u32, // 0x20, Enclosure management control
|
||||
pub capabilities_ext: AhciCapabilitiesExtended,
|
||||
pub bohc: AhciBiosHandoffControl,
|
||||
pub capabilities: Volatile<AhciCapabilities>,
|
||||
pub global_host_control: Volatile<AhciGlobalControl>,
|
||||
pub interrupt_status: Volatile<u32>,
|
||||
pub port_implemented: Volatile<u32>,
|
||||
pub version: Volatile<u32>,
|
||||
pub ccc_ctl: Volatile<u32>, // 0x14, Command completion coalescing control
|
||||
pub ccc_pts: Volatile<u32>, // 0x18, Command completion coalescing ports
|
||||
pub em_loc: Volatile<u32>, // 0x1C, Enclosure management location
|
||||
pub em_ctl: Volatile<u32>, // 0x20, Enclosure management control
|
||||
pub capabilities_ext: Volatile<AhciCapabilitiesExtended>,
|
||||
pub bohc: Volatile<AhciBiosHandoffControl>,
|
||||
}
|
||||
|
||||
impl AhciHba {
|
||||
pub fn init(&mut self) {
|
||||
self.global_host_control.update(|ghc| {
|
||||
ghc.set_hba_reset(true);
|
||||
});
|
||||
|
||||
mammoth::syscall::thread_sleep(50).unwrap();
|
||||
|
||||
loop {
|
||||
if !self.global_host_control.read().hba_reset() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self.global_host_control.update(|ghc| {
|
||||
ghc.set_ahci_enable(true);
|
||||
});
|
||||
|
||||
mammoth::syscall::thread_sleep(50).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue