Pin additons
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from .board_profile import board_comment_for_instruction, board_json_payload, board_metadata_for_instruction
|
||||
from .cycles import cycle_comment
|
||||
from .dataflow import state_for_instruction
|
||||
from .dtc import DtcEndpointInfo, DtcRegisterInfo
|
||||
@@ -19,6 +20,11 @@ from .peripheral_access import (
|
||||
)
|
||||
from .rom import Rom
|
||||
from .sci import sci_comment_for_instruction, sci_json_payload, sci_metadata_for_instruction
|
||||
from .sci_protocol import (
|
||||
sci_protocol_comment_for_instruction,
|
||||
sci_protocol_json_payload,
|
||||
sci_protocol_metadata_for_instruction,
|
||||
)
|
||||
from .symbols import symbol_for_address
|
||||
from .tables import IO_REGISTERS
|
||||
from .timing import format_timing_summary
|
||||
@@ -217,6 +223,31 @@ def _lcd_driver_lines(lcd_driver: dict[str, object] | None) -> list[str]:
|
||||
return lines
|
||||
|
||||
|
||||
def _board_profile_lines(board_profile: dict[str, object] | None) -> list[str]:
|
||||
if not board_profile:
|
||||
return []
|
||||
traces = board_profile.get("traces", [])
|
||||
if not isinstance(traces, list) or not traces:
|
||||
return []
|
||||
|
||||
lines = ["; Board Profile"]
|
||||
summary = board_profile.get("summary")
|
||||
if summary:
|
||||
lines.append(f"; {summary}")
|
||||
for trace in traces:
|
||||
if not isinstance(trace, dict):
|
||||
continue
|
||||
lines.append(
|
||||
f"; H8 pin {trace['h8_pin']} {trace['h8_pin_name']} "
|
||||
f"({trace['signal']}) -> MAX202 pin {trace['max202_pin']}",
|
||||
)
|
||||
state = board_profile.get("state")
|
||||
if isinstance(state, dict) and state.get("P9SCI2E") is False:
|
||||
lines.append("; SCI2 pin routing is disabled by SYSCR2.P9SCI2E=0 in the observed setup.")
|
||||
lines.append("")
|
||||
return lines
|
||||
|
||||
|
||||
def format_listing(
|
||||
rom_path: Path,
|
||||
rom: Rom,
|
||||
@@ -230,6 +261,8 @@ def format_listing(
|
||||
timing_summary: dict[str, list[dict[str, object]]] | None = None,
|
||||
show_cycles: bool = False,
|
||||
sci_analysis: dict[str, object] | None = None,
|
||||
sci_protocol: dict[str, object] | None = None,
|
||||
board_profile: dict[str, object] | None = None,
|
||||
peripheral_access: dict[str, object] | None = None,
|
||||
indirect_flow: dict[str, object] | None = None,
|
||||
dataflow: dict[str, object] | None = None,
|
||||
@@ -294,6 +327,7 @@ def format_listing(
|
||||
lines.append("")
|
||||
|
||||
lines.extend(_symbol_lines(symbols))
|
||||
lines.extend(_board_profile_lines(board_profile))
|
||||
lines.extend(_lcd_text_lines(lcd_text))
|
||||
lines.extend(_lcd_driver_lines(lcd_driver))
|
||||
|
||||
@@ -312,6 +346,8 @@ def format_listing(
|
||||
for part in (
|
||||
ins.comment,
|
||||
sci_comment_for_instruction(sci_analysis, address),
|
||||
sci_protocol_comment_for_instruction(sci_protocol, address),
|
||||
board_comment_for_instruction(board_profile, address),
|
||||
peripheral_comment_for_instruction(peripheral_access, address),
|
||||
indirect_comment_for_instruction(indirect_flow, address),
|
||||
lcd_text_comment_for_instruction(lcd_text, address),
|
||||
@@ -338,6 +374,8 @@ def write_json(
|
||||
call_graph: dict[str, object] | None = None,
|
||||
timing_summary: dict[str, list[dict[str, object]]] | None = None,
|
||||
sci_analysis: dict[str, object] | None = None,
|
||||
sci_protocol: dict[str, object] | None = None,
|
||||
board_profile: dict[str, object] | None = None,
|
||||
peripheral_access: dict[str, object] | None = None,
|
||||
indirect_flow: dict[str, object] | None = None,
|
||||
dataflow: dict[str, object] | None = None,
|
||||
@@ -365,6 +403,8 @@ def write_json(
|
||||
"call_graph": call_graph or {"nodes": [], "edges": []},
|
||||
"timing_summary": timing_summary or {"blocks": [], "loops": []},
|
||||
"sci": sci_json_payload(sci_analysis),
|
||||
"sci_protocol": sci_protocol_json_payload(sci_protocol),
|
||||
"board_profile": board_json_payload(board_profile),
|
||||
"peripheral_access": peripheral_json_payload(peripheral_access),
|
||||
"indirect_flow": indirect_flow or {"sites": []},
|
||||
"dataflow": _dataflow_json_payload(dataflow),
|
||||
@@ -372,7 +412,18 @@ def write_json(
|
||||
"lcd_text": lcd_text or {"strings": [], "regions": [], "searches": []},
|
||||
"lcd_driver": lcd_driver or {"accesses": [], "polling_loops": [], "routines": []},
|
||||
"instructions": [
|
||||
_instruction_payload(ins, sci_analysis, peripheral_access, indirect_flow, dataflow, symbols, lcd_text, lcd_driver)
|
||||
_instruction_payload(
|
||||
ins,
|
||||
sci_analysis,
|
||||
sci_protocol,
|
||||
board_profile,
|
||||
peripheral_access,
|
||||
indirect_flow,
|
||||
dataflow,
|
||||
symbols,
|
||||
lcd_text,
|
||||
lcd_driver,
|
||||
)
|
||||
for ins in (instructions[addr] for addr in sorted(instructions))
|
||||
],
|
||||
}
|
||||
@@ -425,6 +476,8 @@ def _dataflow_instruction_payload(dataflow: dict[str, object] | None, address: i
|
||||
def _instruction_payload(
|
||||
ins: Instruction,
|
||||
sci_analysis: dict[str, object] | None = None,
|
||||
sci_protocol: dict[str, object] | None = None,
|
||||
board_profile: dict[str, object] | None = None,
|
||||
peripheral_access: dict[str, object] | None = None,
|
||||
indirect_flow: dict[str, object] | None = None,
|
||||
dataflow: dict[str, object] | None = None,
|
||||
@@ -458,6 +511,12 @@ def _instruction_payload(
|
||||
sci_metadata = sci_metadata_for_instruction(sci_analysis, ins.address)
|
||||
if sci_metadata:
|
||||
payload["sci"] = sci_metadata
|
||||
sci_protocol_metadata = sci_protocol_metadata_for_instruction(sci_protocol, ins.address)
|
||||
if sci_protocol_metadata:
|
||||
payload["sci_protocol"] = sci_protocol_metadata
|
||||
board_metadata = board_metadata_for_instruction(board_profile, ins.address)
|
||||
if board_metadata:
|
||||
payload["board_profile"] = board_metadata
|
||||
peripheral_metadata = peripheral_metadata_for_instruction(peripheral_access, ins.address)
|
||||
if peripheral_metadata:
|
||||
payload["peripheral_access"] = peripheral_metadata
|
||||
|
||||
Reference in New Issue
Block a user