MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / get_device

Method get_device

pci/src/device.rs:53–89  ·  view source on GitHub ↗

Return the Device which is at this PCI bus location May return None if there is no device

(&self)

Source from the content-addressed store, hash-verified

51 /// Return the Device which is at this PCI bus location
52 /// May return None if there is no device
53 pub fn get_device(&self) -> Option<Device> {
54 let reg_0 = self.read_register(0);
55 if reg_0 == 0xFFFF_FFFF {
56 return None // No device
57 }
58
59 let vendor_id = (reg_0 & 0xFFFF) as u16;
60 let device_id = (reg_0 >> 16) as u16;
61
62 let reg_2 = self.read_register(2);
63
64 let revision_id = (reg_2 & 0xFF) as u8;
65 let prog_if = ((reg_2 >> 8) & 0xFF) as u8;
66 let subclass = ((reg_2 >> 16) & 0xFF) as u8;
67 let class = ((reg_2 >> 24) & 0xFF) as u8;
68
69 let reg_3 = self.read_register(3);
70
71 let header_type = ((reg_3 >> 16) & 0xFF) as u8;
72
73 let subsystem_id = if header_type == 0 {
74 let reg_B = self.read_register(0xB);
75 ((reg_B >> 16) & 0xFFFF) as u16
76 } else { 0 };
77
78 Some(Device {
79 location: self.clone(),
80 vendor_id,
81 device_id,
82 class,
83 subclass,
84 prog_if,
85 revision_id,
86 header_type,
87 subsystem_id
88 })
89 }
90}
91
92/// Information about a PCI device

Callers 1

mainFunction · 0.80

Calls 2

read_registerMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected