linux.py: Implement TSO

Signed-off-by: Asahi Lina <lina@asahilina.net>
This commit is contained in:
Asahi Lina 2023-03-22 17:36:37 +09:00 committed by Hector Martin
parent fa3dcd3e77
commit 8bf08b0ff1

View file

@ -14,6 +14,7 @@ parser.add_argument('--compression', choices=['auto', 'none', 'gz', 'xz'], defau
parser.add_argument('-b', '--bootargs', type=str, metavar='"boot arguments"')
parser.add_argument('-t', '--tty', type=str)
parser.add_argument('-u', '--u-boot', type=pathlib.Path, help="load u-boot before linux")
parser.add_argument('-T', '--tso', action="store_true", help="enable TSO")
args = parser.parse_args()
from m1n1.setup import *
@ -112,6 +113,18 @@ if args.u_boot:
p.smp_start_secondaries()
if args.tso:
print("Enabling TSO:")
actlr = u.mrs("ACTLR_EL1")
actlr |= (1 << 1) # TSO
print(" CPU #0")
u.msr("ACTLR_EL1", actlr)
for i in range(1, 64):
if p.smp_is_alive(i):
print(f" CPU #{i}")
u.msr("ACTLR_EL1", actlr, call=lambda addr, *args: p.smp_call_sync(i, addr & ~REGION_RX_EL1, *args))
p.kboot_set_chosen("apple,tso", "")
if p.kboot_prepare_dt(dtb_addr):
print("DT prepare failed")
sys.exit(1)