forked from koniifer/ableos
IDE: Rename PiixIde to PciIde, use it for all IDE controllers
If the controller is not a known PCI IDE controller, then we warn about the controller during PCI device discovery. :^)
This commit is contained in:
parent
f140938ee6
commit
8a1c77db58
|
@ -8,7 +8,6 @@ use core::panic::PanicInfo;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
arch::gdt,
|
arch::gdt,
|
||||||
devices::pci::{PciDevice, PCI_DEVICES},
|
|
||||||
println,
|
println,
|
||||||
rhai_shell::KEYBUFF,
|
rhai_shell::KEYBUFF,
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
use serde::de::value;
|
|
||||||
use x86_64::instructions::port::Port;
|
use x86_64::instructions::port::Port;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -16,7 +15,7 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: Unknown class
|
// FIXME: Unknown class
|
||||||
pub const S3INC_TRIO64V2: DeviceID = DeviceID::new(S3Inc, 0x8900);
|
pub const S3_TRIO64V2: DeviceID = DeviceID::new(S3Inc, 0x8900);
|
||||||
|
|
||||||
// MassStorage_IDE (0x0101)
|
// MassStorage_IDE (0x0101)
|
||||||
pub const INTEL_PIIX3_IDE: DeviceID = DeviceID::new(IntelCorp, 0x7010);
|
pub const INTEL_PIIX3_IDE: DeviceID = DeviceID::new(IntelCorp, 0x7010);
|
||||||
|
|
|
@ -4,13 +4,11 @@
|
||||||
* SPDX-License-Identifier: MPL-2.0
|
* SPDX-License-Identifier: MPL-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use core::mem;
|
|
||||||
use core::num::TryFromIntError;
|
use core::num::TryFromIntError;
|
||||||
|
|
||||||
use x86_64::instructions::port::Port;
|
// FIXME: platform agnostic-ify these
|
||||||
use x86_64::instructions::{hlt, interrupts};
|
use x86_64::instructions::{port::Port, interrupts};
|
||||||
use x86_64::structures::paging::{FrameAllocator, FrameDeallocator};
|
use x86_64::structures::paging::{FrameAllocator, FrameDeallocator};
|
||||||
// FIXME: platform agnostic paging stuff
|
|
||||||
use x86_64::structures::paging::{mapper::MapToError, Mapper, Page, PhysFrame, Size4KiB};
|
use x86_64::structures::paging::{mapper::MapToError, Mapper, Page, PhysFrame, Size4KiB};
|
||||||
use x86_64::VirtAddr;
|
use x86_64::VirtAddr;
|
||||||
|
|
||||||
|
@ -75,7 +73,7 @@ const CMD_IDENTIFY: u8 = 0xEC;
|
||||||
/// ATA read using LBA48 DMA command
|
/// ATA read using LBA48 DMA command
|
||||||
const CMD_READ_DMA_EXT: u8 = 0x25;
|
const CMD_READ_DMA_EXT: u8 = 0x25;
|
||||||
|
|
||||||
pub struct PiixIde {
|
pub struct PciIde {
|
||||||
device_info: PciDeviceInfo,
|
device_info: PciDeviceInfo,
|
||||||
ide_devices: Vec<IdeDevice>,
|
ide_devices: Vec<IdeDevice>,
|
||||||
prdt_frame: Option<PhysFrame>,
|
prdt_frame: Option<PhysFrame>,
|
||||||
|
@ -83,7 +81,7 @@ pub struct PiixIde {
|
||||||
bmiba: u16,
|
bmiba: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PiixIde {
|
impl PciIde {
|
||||||
// FIXME: make this return a Result
|
// FIXME: make this return a Result
|
||||||
pub fn new(bus: u8, device: u8) -> Option<Self> {
|
pub fn new(bus: u8, device: u8) -> Option<Self> {
|
||||||
let device_info = check_device(bus, device)?;
|
let device_info = check_device(bus, device)?;
|
|
@ -9,7 +9,7 @@ pub mod device;
|
||||||
pub mod vendors;
|
pub mod vendors;
|
||||||
|
|
||||||
// MassStorage_IDE (0x0101)
|
// MassStorage_IDE (0x0101)
|
||||||
pub mod piix_ide;
|
pub mod ide;
|
||||||
|
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
pub use class::*;
|
pub use class::*;
|
||||||
|
@ -20,7 +20,8 @@ use x86_64::structures::paging::{Mapper, Size4KiB};
|
||||||
|
|
||||||
use crate::arch::memory::BootInfoFrameAllocator;
|
use crate::arch::memory::BootInfoFrameAllocator;
|
||||||
|
|
||||||
use self::piix_ide::PiixIde;
|
// MassStorage_IDE (0x0101)
|
||||||
|
use self::ide::PciIde;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref PCI_DEVICES: Mutex<Vec<Arc<Mutex<PciDevice>>>> = Default::default();
|
pub static ref PCI_DEVICES: Mutex<Vec<Arc<Mutex<PciDevice>>>> = Default::default();
|
||||||
|
@ -28,8 +29,7 @@ lazy_static! {
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum PciDevice {
|
pub enum PciDevice {
|
||||||
// MassStorage_IDE (0x0101)
|
Ide(PciIde),
|
||||||
PiixIde(PiixIde),
|
|
||||||
// Variant so that we aren't about irrefutable if-let patterns
|
// Variant so that we aren't about irrefutable if-let patterns
|
||||||
// FIXME: remove as soon as we have other variants
|
// FIXME: remove as soon as we have other variants
|
||||||
_0,
|
_0,
|
||||||
|
@ -43,24 +43,26 @@ pub fn init(mapper: &mut impl Mapper<Size4KiB>, frame_allocator: &mut BootInfoFr
|
||||||
trace!("{device_info}");
|
trace!("{device_info}");
|
||||||
match device_info.device_id {
|
match device_info.device_id {
|
||||||
// FIXME: Unknown class
|
// FIXME: Unknown class
|
||||||
S3INC_TRIO64V2 => {}
|
S3_TRIO64V2 => {}
|
||||||
|
|
||||||
// MassStorage_IDE (0x0101)
|
// MassStorage_IDE (0x0101)
|
||||||
INTEL_PIIX3_IDE | INTEL_PIIX4_IDE => {
|
ide_controller if device_info.full_class == PciFullClass::MassStorage_IDE => {
|
||||||
let mut piix = PiixIde::new(bus, device).unwrap();
|
if !matches!(ide_controller, INTEL_PIIX3_IDE | INTEL_PIIX4_IDE) {
|
||||||
piix.allocate_dma_frame(mapper, frame_allocator).unwrap();
|
// not one of our tested IDE controllers, but
|
||||||
|
// we shouldn't have any problems
|
||||||
|
warn!("Unsupported PCI IDE controller device {device} on bus {bus}")
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut ide = PciIde::new(bus, device).unwrap();
|
||||||
|
ide.allocate_dma_frame(mapper, frame_allocator).unwrap();
|
||||||
let mut devices = PCI_DEVICES.lock();
|
let mut devices = PCI_DEVICES.lock();
|
||||||
devices.push(Arc::new(Mutex::new(PciDevice::PiixIde(piix))));
|
devices.push(Arc::new(Mutex::new(PciDevice::Ide(ide))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display_VGA (0x0300)
|
// Display_VGA (0x0300)
|
||||||
VMWARE_SVGA2 => {}
|
VMWARE_SVGA2 => {}
|
||||||
_ => {
|
_ => {
|
||||||
trace!(
|
trace!("Unknown PCI device {device} on bus {bus}")
|
||||||
"PCI device {} on bus {} unsupported",
|
|
||||||
device_info.device,
|
|
||||||
device_info.bus
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ pub fn scratchpad() {
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|device_ref| {
|
.find_map(|device_ref| {
|
||||||
let device = device_ref.lock();
|
let device = device_ref.lock();
|
||||||
if let PciDevice::PiixIde(_) = &*device {
|
if let PciDevice::Ide(_) = &*device {
|
||||||
Some(device_ref.clone())
|
Some(device_ref.clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -128,7 +128,7 @@ pub fn scratchpad() {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
let mut piix_ide_device = piix_ide_device.lock();
|
let mut piix_ide_device = piix_ide_device.lock();
|
||||||
if let PciDevice::PiixIde(device) = &mut *piix_ide_device {
|
if let PciDevice::Ide(device) = &mut *piix_ide_device {
|
||||||
device.read().unwrap()
|
device.read().unwrap()
|
||||||
}
|
}
|
||||||
real_shell();
|
real_shell();
|
||||||
|
|
Loading…
Reference in a new issue