tools/litex_server: move PCIe specific bar renaming/enable to comm_pcie.
This commit is contained in:
parent
595c6738a3
commit
ad62e15d98
|
@ -217,14 +217,6 @@ def main():
|
||||||
if pcie_bar is None:
|
if pcie_bar is None:
|
||||||
print("Need to speficy --pcie-bar, exiting.")
|
print("Need to speficy --pcie-bar, exiting.")
|
||||||
exit()
|
exit()
|
||||||
if "/sys/bus/pci/devices" not in pcie_bar:
|
|
||||||
pcie_bar = f"/sys/bus/pci/devices/0000:{args.pcie_bar}/resource0"
|
|
||||||
# Enable PCIe device is not already enabled.
|
|
||||||
enable = open(pcie_bar.replace("resource0", "enable"), "r+")
|
|
||||||
if enable.read(1) == "0":
|
|
||||||
enable.seek(0)
|
|
||||||
enable.write("1")
|
|
||||||
enable.close()
|
|
||||||
print("[CommPCIe] bar: {} / ".format(pcie_bar), end="")
|
print("[CommPCIe] bar: {} / ".format(pcie_bar), end="")
|
||||||
comm = CommPCIe(pcie_bar, debug=args.debug)
|
comm = CommPCIe(pcie_bar, debug=args.debug)
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,21 @@ from litex.tools.remote.csr_builder import CSRBuilder
|
||||||
class CommPCIe(CSRBuilder):
|
class CommPCIe(CSRBuilder):
|
||||||
def __init__(self, bar, csr_csr=None, debug=False):
|
def __init__(self, bar, csr_csr=None, debug=False):
|
||||||
CSRBuilder.__init__(self, comm=self, csr_csv=csr_csv)
|
CSRBuilder.__init__(self, comm=self, csr_csv=csr_csv)
|
||||||
|
if "/sys/bus/pci/devices" not in bar:
|
||||||
|
bar = f"/sys/bus/pci/devices/0000:{bar}/resource0"
|
||||||
self.bar = bar
|
self.bar = bar
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
|
|
||||||
|
self.enable()
|
||||||
|
|
||||||
|
def enable(self):
|
||||||
|
# Enable PCIe device is not already enabled.
|
||||||
|
enable = open(self.bar.replace("resource0", "enable"), "r+")
|
||||||
|
if enable.read(1) == "0":
|
||||||
|
enable.seek(0)
|
||||||
|
enable.write("1")
|
||||||
|
enable.close()
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
if hasattr(self, "file"):
|
if hasattr(self, "file"):
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue