Stub out nested routes

This commit is contained in:
zvecr
2022-09-26 01:09:15 +01:00
parent 017ee1ec30
commit 76a45a4e24
6 changed files with 50 additions and 10 deletions
@@ -53,6 +53,8 @@ def _get_route_type(container):
return 'XAP_CONST_MEM'
elif container['return_type'] == 'u32':
return 'XAP_CONST_MEM'
elif container['return_type'] == 'u64':
return 'XAP_CONST_MEM'
elif container['return_type'] == 'struct':
return 'XAP_CONST_MEM'
elif container['return_type'] == 'string':
@@ -98,6 +100,11 @@ def _append_routing_table_declaration(lines, container, container_id, route_stac
lines.append('')
lines.append(f'static const uint32_t {route_name}_data PROGMEM = {constant};')
elif container['return_type'] == 'u64':
constant = container['return_constant']
lines.append('')
lines.append(f'static const uint64_t {route_name}_data PROGMEM = {constant};')
elif container['return_type'] == 'struct':
lines.append('')
lines.append(f'static const {route_name}_t {route_name}_data PROGMEM = {{')
@@ -196,6 +203,8 @@ def _append_routing_table_entry(lines, container, container_id, route_stack):
_append_routing_table_entry_const_data(lines, container, container_id, route_stack)
elif container['return_type'] == 'u32':
_append_routing_table_entry_const_data(lines, container, container_id, route_stack)
elif container['return_type'] == 'u64':
_append_routing_table_entry_const_data(lines, container, container_id, route_stack)
elif container['return_type'] == 'struct':
_append_routing_table_entry_const_data(lines, container, container_id, route_stack)
elif container['return_type'] == 'string':
+6 -2
View File
@@ -147,8 +147,12 @@ class XAPDevice(XAPDeviceBase):
XAPRouteError: Access to invalid route attempted
"""
# TODO: Remove assumption that capability is always xx01
(sub, rt) = route
cap = bytes([sub, 1])
(remain, sub, rt) = (route[:-2], route[-2], route[-1])
cap = remain + bytes([sub, 1])
# recurse for nested routes
if remain:
self._ensure_route(remain + bytes([sub]))
if self.subsystems() & (1 << sub) == 0:
raise XAPRouteError("subsystem not available")