Compare commits
4 commits
6cc3a29828
...
29b007c2af
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29b007c2af | ||
|
|
6c8f248e3e | ||
|
|
5a71e7611f | ||
|
|
605b40a8f7 |
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -160,3 +160,5 @@ 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
|
||||||
|
|
@ -14,11 +14,30 @@ 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):
|
||||||
with open(f"/sys/bus/pci/devices/{self.device_id}/driver/unbind",
|
driver_unbind_path = f"/sys/bus/pci/devices/{self.device_id}/driver/unbind"
|
||||||
"w") as device_driver:
|
if not exists(driver_unbind_path):
|
||||||
|
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()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue