EMualtor adjustments
This commit is contained in:
@@ -668,6 +668,15 @@ def _gate_queue_predicate_function_lines(value: object) -> list[str]:
|
||||
" return MEM8[0xF9B5u] != MEM8[0xF9B0u];",
|
||||
"}",
|
||||
"",
|
||||
"static bool sci1_candidate_idle_heartbeat_enqueue_gate_open(void)",
|
||||
"{",
|
||||
" bool idle_timer_clear = MEM8[0xF9C4u] == 0u;",
|
||||
" bool rx_gate_open = (MEM8[0xFAA5u] & 0x80u) == 0u || MEM8[0xF9C3u] == 0u;",
|
||||
" bool queue_empty = MEM8[0xF9B0u] == MEM8[0xF9B5u];",
|
||||
"",
|
||||
" return idle_timer_clear && rx_gate_open && queue_empty;",
|
||||
"}",
|
||||
"",
|
||||
"static bool sci1_candidate_periodic_resend_gate_open(void)",
|
||||
"{",
|
||||
" bool pending = (MEM8[0xFAA5u] & MEM8[0xFAA3u] & 0x80u) != 0u;",
|
||||
@@ -759,12 +768,21 @@ def _timer_architecture_comment_lines(
|
||||
if not model:
|
||||
return []
|
||||
|
||||
vector = str(model.get("vector_address_hex") or "H'BEEA")
|
||||
source = str(model.get("source") or "FRT1 OCIA")
|
||||
lines = [f"{prefix}interrupt/timer architecture candidate:"]
|
||||
lines.append(
|
||||
f"{prefix}- {source} {vector} appears to be a periodic tick ISR for serial gate/cadence counters.",
|
||||
)
|
||||
sources = _timer_source_models(model)
|
||||
if sources:
|
||||
for source_model in sources:
|
||||
source = str(source_model.get("source") or "timer")
|
||||
handler = str(source_model.get("handler_address_hex") or source_model.get("vector_address_hex") or "")
|
||||
details = f" {handler}" if handler else ""
|
||||
summary = _comment_text(str(source_model.get("summary") or "appears to be a periodic tick ISR for serial counters."))
|
||||
lines.append(f"{prefix}- {source}{details}: {summary}")
|
||||
else:
|
||||
vector = str(model.get("vector_address_hex") or model.get("handler_address_hex") or "H'BEEA")
|
||||
source = str(model.get("source") or "FRT1 OCIA")
|
||||
lines.append(
|
||||
f"{prefix}- {source} {vector} appears to be a periodic tick ISR for serial gate/cadence counters.",
|
||||
)
|
||||
counters = _timer_counter_models(model)
|
||||
for counter in counters:
|
||||
address = counter.get("address_hex") or _h(_int_field(counter, "address", 0))
|
||||
@@ -781,14 +799,39 @@ def _timer_architecture_function_lines(protocol: JsonObject) -> list[str]:
|
||||
model = _timer_architecture_model(protocol)
|
||||
if not model:
|
||||
return []
|
||||
sources = _timer_source_models(model)
|
||||
if sources:
|
||||
lines: list[str] = []
|
||||
for source_model in sources:
|
||||
counters = _timer_counter_models(source_model)
|
||||
if not counters:
|
||||
continue
|
||||
source = str(source_model.get("source") or "timer")
|
||||
handler = str(source_model.get("handler_address_hex") or source_model.get("vector_address_hex") or "")
|
||||
lines.extend(
|
||||
_timer_tick_function_lines(
|
||||
_timer_source_function_name(source),
|
||||
counters,
|
||||
f"Candidate periodic tick at {handler or source}: decrement nonzero serial counters.",
|
||||
)
|
||||
)
|
||||
return lines
|
||||
counters = _timer_counter_models(model)
|
||||
if not counters:
|
||||
return []
|
||||
|
||||
return _timer_tick_function_lines(
|
||||
"frt1_ocia_candidate_tick_isr",
|
||||
counters,
|
||||
"Candidate periodic tick at H'BEEA: decrement nonzero serial gate/cadence counters.",
|
||||
)
|
||||
|
||||
|
||||
def _timer_tick_function_lines(function_name: str, counters: list[JsonObject], summary: str) -> list[str]:
|
||||
lines = [
|
||||
"void frt1_ocia_candidate_tick_isr(void)",
|
||||
f"void {function_name}(void)",
|
||||
"{",
|
||||
" /* Candidate periodic tick at H'BEEA: decrement nonzero serial gate/cadence counters. */",
|
||||
f" /* {_comment_text(summary)} */",
|
||||
]
|
||||
for counter in counters:
|
||||
address = _int_field(counter, "address", 0)
|
||||
@@ -808,14 +851,23 @@ def _timer_architecture_function_lines(protocol: JsonObject) -> list[str]:
|
||||
return lines
|
||||
|
||||
|
||||
def _timer_source_models(model: JsonObject) -> list[JsonObject]:
|
||||
return _object_list(model.get("sources"))
|
||||
|
||||
|
||||
def _timer_source_function_name(source: str) -> str:
|
||||
root = _safe_identifier(source.lower().replace(" ", "_"))
|
||||
return f"{root}_candidate_tick_isr"
|
||||
|
||||
|
||||
def _timer_architecture_model(protocol: JsonObject) -> JsonObject:
|
||||
model = protocol.get("timer_interrupt_model")
|
||||
if isinstance(model, dict):
|
||||
return model
|
||||
if isinstance(protocol.get("gate_queue_model"), dict) or isinstance(protocol.get("periodic_resend_model"), dict):
|
||||
return {
|
||||
"source": "FRT1 OCIA",
|
||||
"vector_address_hex": "H'BEEA",
|
||||
"source": "FRT1/FRT2 OCIA",
|
||||
"vector_address_hex": "H'BEEA/H'BF23",
|
||||
"counters": [
|
||||
{
|
||||
"address": 0xF9C0,
|
||||
@@ -835,6 +887,12 @@ def _timer_architecture_model(protocol: JsonObject) -> JsonObject:
|
||||
"name_candidate": "periodic_resend_cadence_counter_candidate",
|
||||
"role": "candidate periodic resend/heartbeat cadence counter.",
|
||||
},
|
||||
{
|
||||
"address": 0xF9C4,
|
||||
"address_hex": "H'F9C4",
|
||||
"name_candidate": "idle_heartbeat_gate_countdown_candidate",
|
||||
"role": "candidate idle/default report enqueue countdown.",
|
||||
},
|
||||
],
|
||||
}
|
||||
return {}
|
||||
@@ -863,6 +921,12 @@ def _timer_counter_models(model: JsonObject) -> list[JsonObject]:
|
||||
"name_candidate": "periodic_resend_cadence_counter_candidate",
|
||||
"role": "candidate periodic resend/heartbeat cadence counter.",
|
||||
},
|
||||
{
|
||||
"address": 0xF9C4,
|
||||
"address_hex": "H'F9C4",
|
||||
"name_candidate": "idle_heartbeat_gate_countdown_candidate",
|
||||
"role": "candidate idle/default report enqueue countdown.",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user