spare fixes

This commit is contained in:
koniifer 2024-08-31 15:29:24 +01:00
parent 9ba18e839a
commit 2c1969e87e
2 changed files with 7 additions and 6 deletions

View file

@ -12,7 +12,8 @@ use crate::alloc::string::ToString;
/// Enumerate PCI devices and run initialisation routines on ones we support
pub fn init(device_tree: &mut DeviceTree) {
device_tree.devices
device_tree
.devices
.insert("Unidentified PCI".to_string(), alloc::vec![]);
let mut devices = alloc::vec![];
@ -23,6 +24,7 @@ pub fn init(device_tree: &mut DeviceTree) {
let id = device_info.device_id.id;
use Vendor::*;
let (dev_type, dev_name) = match (vendor, id) {
(VMWareInc, 1029) => ("GPUs", "SVGAII PCI GPU"),
(Qemu, 4369) => ("GPUs", "QEMU VGA"),
(VirtIO, 4176) => ("GPUs", "VirtIO PCI GPU"),
(CirrusLogic, 184) => ("GPUs", "Cirrus SVGA"), //GD 5446?
@ -269,8 +271,7 @@ impl Display for Vendor {
use core::fmt::Display;
use x86_64::instructions::port::Port;
use crate::device_tree::DeviceTree;
use {crate::device_tree::DeviceTree, x86_64::instructions::port::Port};
#[allow(non_camel_case_types, dead_code)]
#[derive(Debug, Clone, Copy, PartialEq)]

View file

@ -6,14 +6,14 @@ get_vendor_id := fn(bus: u8, device: u8, function: u8): u16 {
return 0
}
pci_config_read_word := fn(bus: u8, slot: u8, func: u8, offset: u8): u16 {
pci_config_read_word := fn(bus: u8, device: u8, func: u8, offset: u8): u16 {
address := @as(u32, 0)
lbus := @as(u32, bus)
lslot := @as(u32, slot)
ldevice := @as(u32, device)
lfunc := @as(u32, func)
tmp := @as(u16, 0)
address = @as(u32, lbus << 16 | lslot << 1 | lfunc << 8 | offset & 252 | @as(u32, 2147483648))
address = @as(u32, lbus << 16 | ldevice << 11 | lfunc << 8 | offset & 252 | @as(u32, 2147483648))
memory.outl(address, 3320)
tmp = @as(u16, memory.inl(3324) >> (offset & 2) * 8 & 65535)
return tmp