Compare commits

..

No commits in common. "29b007c2afa6e456d8ee91a2dc2fe65b9feb3e01" and "6cc3a29828ff6f4394f206926a71a0dc8bbd11ae" have entirely different histories.

2 changed files with 2 additions and 23 deletions

2
.gitignore vendored
View file

@ -160,5 +160,3 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear # and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
/*util.sh

View file

@ -14,30 +14,11 @@ class PciDevice:
def is_vga(self) -> bool: def is_vga(self) -> bool:
return exists(f"/sys/bus/pci/devices/{self.device_id}/boot_vga") return exists(f"/sys/bus/pci/devices/{self.device_id}/boot_vga")
def vendor_code(self, remove_prefix: bool = True) -> str:
with open(f"/sys/bus/pci/devices/{self.device_id}/vendor") as vendor:
return vendor.read() if not remove_prefix else vendor.read(
).lstrip("0x")
def device_code(self, remove_prefix: bool = True) -> str:
with open(f"/sys/bus/pci/devices/{self.device_id}/vendor") as device:
return device.read() if not remove_prefix else device.read(
).lstrip("0x")
def unbind_driver(self): def unbind_driver(self):
driver_unbind_path = f"/sys/bus/pci/devices/{self.device_id}/driver/unbind" with open(f"/sys/bus/pci/devices/{self.device_id}/driver/unbind",
if not exists(driver_unbind_path): "w") as device_driver:
print("Device is not bound to any driver.")
return
with open(driver_unbind_path, "w") as device_driver:
device_driver.write(self.device_id) device_driver.write(self.device_id)
def set_driver_override(self, reserved_for_driver: str):
with open(f"/sys/bus/pci/devices/{self.device_id}/driver_override",
"w") as driver_override:
driver_override.write(reserved_for_driver)
def bind_to_driver(self, driver_to_bind: str, unbind_first: bool = True): def bind_to_driver(self, driver_to_bind: str, unbind_first: bool = True):
if unbind_first: if unbind_first:
self.unbind_driver() self.unbind_driver()