experiments/pcie_enable_devices.py: New script

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2021-12-21 20:14:56 +09:00
parent 1a77571557
commit 054e437c31
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
import sys, pathlib
sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))
from m1n1.setup import *
from m1n1.fw.smc import SMCClient
smc_addr = u.adt["arm-io/smc"].get_reg(0)[0]
smc = SMCClient(u, smc_addr, None)
smc.start()
smc.start_ep(0x20)
smc.smcep.write32("gP0d", 0x800001)
smc.smcep.write32("gP1a", 1)
smc.stop()

View file

@ -1,5 +1,6 @@
# SPDX-License-Identifier: MIT
from ..utils import *
import time
class R_OUTBOX_CTRL(Register32):
EMPTY = 17
@ -25,6 +26,8 @@ class R_OUTBOX1(Register64):
class ASCRegs(RegMap):
CPU_CONTROL = 0x0044, R_CPU_CONTROL
CPU_STATUS = 0x0048, Register32
INBOX_CTRL = 0x8110, R_INBOX_CTRL
OUTBOX_CTRL = 0x8114, R_OUTBOX_CTRL
INBOX0 = 0x8800, Register64
@ -32,6 +35,9 @@ class ASCRegs(RegMap):
OUTBOX0 = 0x8830, Register64
OUTBOX1 = 0x8838, R_OUTBOX1
NMI1 = 0x10004, Register32
NMI2 = 0x10024, Register32
class ASC:
def __init__(self, u, asc_base):
self.u = u
@ -40,6 +46,14 @@ class ASC:
self.asc = ASCRegs(u, asc_base)
self.epmap = {}
def send_nmi(self):
print("send nmi")
#self.asc.NMI1.val = 0x11
#self.asc.NMI2.val = 0x1
def get_status(self):
return self.asc.CPU_STATUS.val
def recv(self):
if self.asc.OUTBOX_CTRL.reg.EMPTY:
return None, None
@ -62,6 +76,7 @@ class ASC:
pass
def boot(self):
#self.send_nmi()
self.asc.CPU_CONTROL.set(RUN=1)
self.asc.CPU_CONTROL.set(RUN=0)