mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 20:22:46 +00:00
config_tools: add RTCT table support in pre-launched VMs
add RTCT table integrated with ACPI binary for pre-launched VMs. Tracked-On: #6015 Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
This commit is contained in:
parent
c08ceb25c5
commit
2247aeed69
@ -15,7 +15,7 @@ TEMPLATE_ACPI_PATH = os.path.join(VM_CONFIGS_PATH, 'acpi_template', 'template')
|
||||
|
||||
ACPI_TABLE_LIST = [('rsdp.asl', 'rsdp.aml'), ('xsdt.asl', 'xsdt.aml'), ('facp.asl', 'facp.aml'),
|
||||
('mcfg.asl', 'mcfg.aml'), ('apic.asl', 'apic.aml'), ('tpm2.asl', 'tpm2.aml'),
|
||||
('dsdt.asl', 'dsdt.aml'), ('PTCT', 'ptct.aml')]
|
||||
('dsdt.asl', 'dsdt.aml'), ('PTCT', 'ptct.aml'), ('RTCT', 'rtct.aml')]
|
||||
|
||||
ACPI_BASE = 0x7ff00000
|
||||
|
||||
@ -25,7 +25,7 @@ ACPI_FADT_ADDR_OFFSET = 0x100 # (268 bytes)
|
||||
ACPI_DSDT_ADDR_OFFSET = 0x240 # (variable)
|
||||
ACPI_MCFG_ADDR_OFFSET = 0x440 # (60 bytes)
|
||||
ACPI_MADT_ADDR_OFFSET = 0x480 # (depends on #CPUs)
|
||||
ACPI_PTCT_ADDR_OFFSET = 0xF00
|
||||
ACPI_RTCT_ADDR_OFFSET = 0xF00
|
||||
ACPI_TPM2_ADDR_OFFSET = 0x1100 # (52 bytes)
|
||||
|
||||
ACPI_RSDP_ADDR = (ACPI_BASE + ACPI_RSDP_ADDR_OFFSET)
|
||||
@ -35,7 +35,7 @@ ACPI_MCFG_ADDR = (ACPI_BASE + ACPI_MCFG_ADDR_OFFSET)
|
||||
ACPI_MADT_ADDR = (ACPI_BASE + ACPI_MADT_ADDR_OFFSET)
|
||||
ACPI_TPM2_ADDR = (ACPI_BASE + ACPI_TPM2_ADDR_OFFSET)
|
||||
ACPI_DSDT_ADDR = (ACPI_BASE + ACPI_DSDT_ADDR_OFFSET)
|
||||
ACPI_PTCT_ADDR = (ACPI_BASE + ACPI_PTCT_ADDR_OFFSET)
|
||||
ACPI_RTCT_ADDR = (ACPI_BASE + ACPI_RTCT_ADDR_OFFSET)
|
||||
ACPI_FACS_ADDR = 0x0
|
||||
|
||||
VIRT_PCI_MMCFG_BASE = 0xE0000000
|
||||
@ -50,4 +50,4 @@ TSN_DEVICE_LIST = ['8086:4ba0',
|
||||
'8086:4bb0',
|
||||
'8086:4b32']
|
||||
|
||||
PTCT = 'PTCT'
|
||||
RTCT = ['RTCT', 'PTCT']
|
||||
|
@ -52,7 +52,7 @@ def gen_xsdt(dest_vm_acpi_path, passthru_devices):
|
||||
p_mcfg_addr = r'ACPI Table Address 1 : ([0-9a-fA-F]{16})'
|
||||
p_madt_addr = r'ACPI Table Address 2 : ([0-9a-fA-F]{16})'
|
||||
p_tpm2_addr = r'ACPI Table Address 3 : ([0-9a-fA-F]{16})'
|
||||
p_ptct_addr = r'ACPI Table Address 4 : ([0-9a-fA-F]{16})'
|
||||
p_rtct_addr = r'ACPI Table Address 4 : ([0-9a-fA-F]{16})'
|
||||
|
||||
with open(os.path.join(dest_vm_acpi_path, xsdt_asl), 'w') as dest:
|
||||
lines = []
|
||||
@ -67,9 +67,9 @@ def gen_xsdt(dest_vm_acpi_path, passthru_devices):
|
||||
elif re.search(p_tpm2_addr, line):
|
||||
if 'TPM2' in passthru_devices:
|
||||
lines.append(re.sub(p_tpm2_addr, 'ACPI Table Address 3 : {0:016X}'.format(ACPI_TPM2_ADDR), line))
|
||||
elif re.search(p_ptct_addr, line):
|
||||
if 'PTCT' in passthru_devices:
|
||||
lines.append(re.sub(p_ptct_addr, 'ACPI Table Address 4 : {0:016X}'.format(ACPI_PTCT_ADDR), line))
|
||||
elif re.search(p_rtct_addr, line):
|
||||
if 'PTCT' in passthru_devices or 'RTCT' in passthru_devices:
|
||||
lines.append(re.sub(p_rtct_addr, 'ACPI Table Address 4 : {0:016X}'.format(ACPI_RTCT_ADDR), line))
|
||||
else:
|
||||
lines.append(line)
|
||||
|
||||
@ -433,11 +433,11 @@ def main(args):
|
||||
if pcpu_id is not None and pcpu_id.text.strip() in pcpu_list:
|
||||
dict_pcpu_list[vm_id].append(int(pcpu_id.text))
|
||||
|
||||
PASSTHROUGH_PTCT = False
|
||||
PASSTHROUGH_RTCT = False
|
||||
PRELAUNCHED_RTVM_ID = None
|
||||
try:
|
||||
if scenario_root.find('hv/FEATURES/SSRAM/SSRAM_ENABLED').text.strip() == 'y':
|
||||
PASSTHROUGH_PTCT = True
|
||||
PASSTHROUGH_RTCT = True
|
||||
for vm in scenario_root.findall('vm'):
|
||||
vm_id = vm.attrib['id']
|
||||
vm_type_node = vm.find('vm_type')
|
||||
@ -445,7 +445,7 @@ def main(args):
|
||||
PRELAUNCHED_RTVM_ID = vm_id
|
||||
break
|
||||
except:
|
||||
PASSTHROUGH_PTCT = False
|
||||
PASSTHROUGH_RTCT = False
|
||||
|
||||
kern_args = common.get_leaf_tag_map(scenario, "os_config", "bootargs")
|
||||
kern_type = common.get_leaf_tag_map(scenario, "os_config", "kern_type")
|
||||
@ -460,9 +460,13 @@ def main(args):
|
||||
dest_vm_acpi_path = os.path.join(DEST_ACPI_PATH, 'ACPI_VM'+vm_id)
|
||||
if not os.path.isdir(dest_vm_acpi_path):
|
||||
os.makedirs(dest_vm_acpi_path)
|
||||
if PASSTHROUGH_PTCT is True and vm_id == PRELAUNCHED_RTVM_ID:
|
||||
passthru_devices.append(PTCT)
|
||||
shutil.copy(os.path.join(VM_CONFIGS_PATH, 'acpi_template', board_type, PTCT), dest_vm_acpi_path)
|
||||
if PASSTHROUGH_RTCT is True and vm_id == PRELAUNCHED_RTVM_ID:
|
||||
for f in RTCT:
|
||||
if os.path.isfile(os.path.join(VM_CONFIGS_PATH, 'acpi_template', board_type, f)):
|
||||
passthru_devices.append(f)
|
||||
shutil.copy(os.path.join(VM_CONFIGS_PATH, 'acpi_template', board_type, f),
|
||||
dest_vm_acpi_path)
|
||||
break
|
||||
gen_rsdp(dest_vm_acpi_path)
|
||||
gen_xsdt(dest_vm_acpi_path, passthru_devices)
|
||||
gen_fadt(dest_vm_acpi_path, board_root)
|
||||
|
@ -33,8 +33,12 @@ def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path):
|
||||
os.remove(os.path.join(dest_vm_acpi_path, acpi_table[1]))
|
||||
rmsg = 'failed to compile {}'.format(acpi_table[0])
|
||||
break
|
||||
elif acpi_table[0] == PTCT:
|
||||
if PTCT in os.listdir(dest_vm_acpi_path):
|
||||
elif acpi_table[0] == 'PTCT':
|
||||
if 'PTCT' in os.listdir(dest_vm_acpi_path):
|
||||
shutil.copyfile(os.path.join(dest_vm_acpi_path, acpi_table[0]),
|
||||
os.path.join(dest_vm_acpi_bin_path, acpi_table[1]))
|
||||
elif acpi_table[0] == 'RTCT':
|
||||
if 'RTCT' in os.listdir(dest_vm_acpi_path):
|
||||
shutil.copyfile(os.path.join(dest_vm_acpi_path, acpi_table[0]),
|
||||
os.path.join(dest_vm_acpi_bin_path, acpi_table[1]))
|
||||
else:
|
||||
@ -96,10 +100,14 @@ def aml_to_bin(dest_vm_acpi_path, dest_vm_acpi_bin_path, acpi_bin_name):
|
||||
with open(os.path.join(dest_vm_acpi_bin_path, ACPI_TABLE_LIST[6][1]), 'rb') as asl:
|
||||
acpi_bin.write(asl.read())
|
||||
|
||||
if PTCT in os.listdir(dest_vm_acpi_path):
|
||||
acpi_bin.seek(ACPI_PTCT_ADDR_OFFSET)
|
||||
if 'PTCT' in os.listdir(dest_vm_acpi_path):
|
||||
acpi_bin.seek(ACPI_RTCT_ADDR_OFFSET)
|
||||
with open(os.path.join(dest_vm_acpi_bin_path, ACPI_TABLE_LIST[7][1]), 'rb') as asl:
|
||||
acpi_bin.write(asl.read())
|
||||
elif 'RTCT' in os.listdir(dest_vm_acpi_path):
|
||||
acpi_bin.seek(ACPI_RTCT_ADDR_OFFSET)
|
||||
with open(os.path.join(dest_vm_acpi_bin_path, ACPI_TABLE_LIST[8][1]), 'rb') as asl:
|
||||
acpi_bin.write(asl.read())
|
||||
|
||||
acpi_bin.seek(0xfffff)
|
||||
acpi_bin.write(b'\0')
|
||||
|
Loading…
Reference in New Issue
Block a user